Php URL重写会弄乱主目录
所以我有这个网址Php URL重写会弄乱主目录,php,.htaccess,url,mod-rewrite,Php,.htaccess,Url,Mod Rewrite,所以我有这个网址 http://localhost/site/ 我还有另一个文件,它看起来像这样 http://localhost/site/info.php?url=website 我把它变成了 http://localhost/site/info/website.com 与 现在当我转到http://localhost/site/ 找不到 在此服务器上找不到请求的URL/info.php 但我只是想访问索引http://localhost/site/非http://localhost/
http://localhost/site/
我还有另一个文件,它看起来像这样
http://localhost/site/info.php?url=website
我把它变成了
http://localhost/site/info/website.com
与
现在当我转到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
site/匹配regex^([a-zA-Z0-9_-]+)/$,因此将被重写为info.php?url=site
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