【发布时间】:2014-12-09 18:26:09
【问题描述】:
重写规则是:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_\-.]+)/?$ storefront.php?id_user=$1 [L]
当放置在子目录中时,即:http://example.com/subdirectory/,它可以将 URL 从http://example.com/subdirectory/user 重定向到http://example.com/subdirectory/storefront.php?id_user=user。
当放置在基本目录即:http://example.com/ 时,它无法将 url http://example.com/user 重定向到 http://example.com/storefront.php?id_user=user
我做错了什么?
【问题讨论】:
-
我尝试访问网址
http://example.com/user,它会将我重定向到http://example.com/ -
此外,我尝试了简单的重写规则,例如将 fileone.html 重写为 storefront.php,当我在基本目录中键入
http://example.com/fileone.html时它可以工作 -
fileone.html 是我尝试验证 rewriteengine 是否从基本目录工作的示例,抱歉造成混淆。只关心原始问题中描述的重写规则。
-
问题中的代码是根目录下的整个.htaccess文件
-
是的,但该规则不会将
http://example.com/user重定向到http://example.com/。
标签: php html apache .htaccess mod-rewrite