问题基本上是这样的:
我有一个网址:site.com?go=1&do=2&action3&id=4
如果我使用这样的重写方法:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)$ /index.php?go=$1
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2&action=$3
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2&action=$3&id=$4
它只适用于第一个Slash。例如:
site.com/go
->这是有效的,但这个site.com/go/do
破坏了整个页面,它找不到css,imgs,什么都没有!我该怎么解决?
谢谢!
您需要在头脑中设置<base>
标签,并将域名放入href
<head>
<base href="http://www.sample.com/">
</head>
根据URL的结构,您可能需要确保您是URL转义后引用。退房https://httpd.apache.org/docs/trunk/rewrite/flags.html