我得到了一些在主要文件夹内工作的重写文件 例如:主文件夹是/ 我把htaccess放在/
这是.htaccess
Options +FollowSymlinks
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^about/(.*)/$ $1.php [L]
RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/$ download-donate.php?product=$1&version=$2&os=$3&method=$4 [L]
RewriteRule ^(.*)/download/(.*)/$ download.php?product=$1&version=$2 [L]
RewriteRule ^subscribe/(.*)/$ subscribe-$1.php [L]
RewriteRule ^subscribe/(.*)/(.*)/$ subscribe-$1.php?email=$2 [L]
RewriteRule ^(.*)/screenshots/$ screenshots.php?product=$1 [L]
RewriteRule ^(.*)/(.*)/$ products.php?product=$1&page=$2 [L]
RewriteRule ^schedule-manager/$ products.php?product=schedule-manager&page=view [L]
RewriteRule ^visual-command-line/$ products.php?product=visual-command-line&page=view [L]
RewriteRule ^windows-hider/$ products.php?product=windows-hider&page=view [L]
RewriteRule ^(.*)/$ $1.php [L]
它在主文件夹中不起作用。 如果我把相同的htaccess(将RewriteBase更改为/ test /)并将其放在名为“test”>的文件夹中/ test /它完美地工作 - 主文件夹和测试文件夹完全相同的文件!
由于
答案 0 :(得分:2)
如果您的托管公司是GoDaddy,请添加
Options -MultiViews
以上
Options +FollowSymlinks
答案 1 :(得分:0)
尝试更改这两个参数的顺序:
RewriteEngine On
RewriteBase /
不确定它会做什么,但这种方式更有意义。
修改
这假设你的代码是/ test /文件夹。
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^about/(.*)/$ test/$1.php [L]
RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/$ test/download-donate.php?product=$1&version=$2&os=$3&method=$4 [L]
RewriteRule ^(.*)/download/(.*)/$ test/download.php?product=$1&version=$2 [L]
RewriteRule ^subscribe/(.*)/$ test/subscribe-$1.php [L]
RewriteRule ^subscribe/(.*)/(.*)/$ test/subscribe-$1.php?email=$2 [L]
RewriteRule ^(.*)/screenshots/$ test/screenshots.php?product=$1 [L]
RewriteRule ^(.*)/(.*)/$ test/products.php?product=$1&page=$2 [L]
RewriteRule ^schedule-manager/$ test/products.php?product=schedule-manager&page=view [L]
RewriteRule ^visual-command-line/$ test/products.php?product=visual-command-line&page=view [L]
RewriteRule ^windows-hider/$ test/products.php?product=windows-hider&page=view [L]
RewriteRule ^(.*)/$ test/$1.php [L]