URL重写会弄乱主目录



我有这个URL

http://localhost/site/

我还有另一个文件它看起来是这样的

http://localhost/site/info.php?url=website

我把它变成了

http://localhost/site/info/website.com

Options +FollowSymLinks
RewriteEngine On
    
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
    
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ info.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ info.php?url=$1
    

转到http://localhost/site/,最后得到

未找到

请求的URL/info.php在此服务器上找不到。

但是我只是想访问索引http://localhost/site/而不是http://localhost/site/info

也许您只想在url以'site/info/'开头时重写

我还没有试过这个,所以它可能不工作…

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteEngine On
RewriteRule ^site/info/([a-zA-Z0-9_-]+)$ info.php?url=$1
RewriteRule ^site/info/([a-zA-Z0-9_-]+)/$ info.php?url=$1

还有,你确定要删除。com当你重写这个…?http://localhost/site/info/website.com

最新更新