English 中文(简体)
用于隐藏 URL 的 mod 重写
原标题:mod rewrite to hide url

我想在以下的 php 文件上隐藏任何请求到 www.example.com/ 。

    www.example.com/index.php  to www.example.com/     (hide index.php)
    www.example.com/content.php to www.example.com/    (hide content.php)
    www.example.com/welcome.php to www.example.com/    (hide welcome.php)

注意 : 我只想隐藏文件而不改变方向。 例如, 隐藏索引. php 或内容部分.php 上的部分, 而不将它们重新定位到 www.example.com/ 。

我试过了

RewriteEngine On

RewriteCond %{THE_REQUEST} ^w+ /(.*).php(?.*)? HTTP/
RewriteRule ^ http://%{HTTP_HOST}/%1 [R=301]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .* $0.php

我也试过

DirectoryIndex index.php
DirectoryIndex content.php
DirectoryIndex welcome.php

这些代码似乎不起作用,知道吗?

最佳回答

如果我没记错的话,这种事情就应该正确。

RewriteRule ^/index.php$ http://www.example.com/ [R,NC,L]
RewriteRule ^/content.php$ http://www.example.com/ [R,NC,L]
RewriteRule ^/welcome.php$ http://www.example.com/ [R,NC,L]

Kind regards,
Bo

问题回答

暂无回答




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签