我的.htaccess代码是:
RewriteRule ^404\.php$ - [L]
Rewritecomnd %{HTTP_HOST} !^www\.example\.com
Rewritecomnd %{HTTP_HOST} ([^.]+)\.example\.com [NC]
RewriteRule ^/?$ /profile/index.php?name=%1 [L]
Rewritecomnd %{HTTP_HOST} !^www\.example\.com
Rewritecomnd %{HTTP_HOST} [^.]+\.example\.com [NC]
Rewritecomnd %{REQUEST_URI} ^/([^/]+)$
RewriteRule !^profile/ /profile/%1 [L]
让我告诉你这是做什么的:
bob.example.com
显示页面www.example.com/profile/index.php?name=bob
bob.example.com/page1.php
仅显示个人资料目录中的页面www.example.com/profile/page1.php
问题:
问题是,如果我转到bob.example.com/directory/page.php
,它会显示我的根目录的目录。我怎么能这样做呢
bob.example.com/directory/page.php
显示www.example.com/profile/directory/page2.php
?
答案 0 :(得分:1)
你的RewriteCond模式与uri /directory/page.php 不匹配。您需要从正则表达式中删除受限制的 / ,或者使用全能模式。
将您的上一次RewriteCond更改为:
RewriteCond %{REQUEST_URI} ^/(.+)$