简体   繁体   English

htacess mod_rewrite无法正常工作(但它可在其他目录的同一服务器上工作)

[英]htacess mod_rewrite not working (But it works on same server in other directory)

So I have this hatcess mod rewrite: 所以我有这个帽子mod重写:

Options +FollowSymlinks
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.com
RewriteRule (.*) http://mysite.com/$1 [R=301,L]
RewriteRule ^/(.*)$ find.php?q=$1 [NC]
RewriteRule ^/(.*)/([0-9])$ find.php?q=$1&psl=$2 [NC]
RewriteRule ^/(.*)/(.*)-links$ find.php?q=$1&hostas=$2 [NC]
RewriteRule ^/(.*)/(.*)-([0-9]+)$ details.php?id=$3 [NC]

The problem is it works perfectly on one of my domains, and it gives 404 error on other domain hosted on same server (hostgator) but in other directory. 问题是它可以在我的一个域上完美运行,并且在同一服务器(hostgator)上但在其他目录中托管的其他域上却给出404错误。 The needed files find.php and detals.php do exist in both directories. 所需的文件find.php和detals.php确实存在于两个目录中。 any suggestions why it doesnt work? 任何建议,为什么它不起作用?

it gives 404 error on other domain hosted on same server but in other directory 它在同一服务器上但在其他目录中托管的其他域上给出404错误

You must define this folder as the base for mod-rewrite in your other folder : 您必须将此文件夹定义为其他文件夹中mod-rewrite的基础:

(...)
RewriteEngine On
RewriteBase /yourfolder/
RewriteCond %{HTTP_HOST} ^www.mysite.com
(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM