[英]Apache Rewrite issue with url with more than 1 slash
The problem is basically this: 问题基本上是这样的:
I have an url: site.com?go=1&do=2&action3&id=4
我有一个网址:
site.com?go=1&do=2&action3&id=4
if i use the rewrite method like this: 如果我使用这样的重写方法:
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
It works only with the first Slash. 它仅适用于第一个斜杠。 for example:
例如:
site.com/go
-> this works but this site.com/go/do
breaks the whole page, it can't find the css, imgs, nothing! site.com/go
>可行,但此site.com/go/do
破坏了整个页面,找不到CSS,img,什么也没有! How can i solve that? 我该如何解决?
Thanks! 谢谢!
You need to set <base>
tag into your head and put your domain name into href 您需要在头上设置
<base>
标记,并将域名放入href
<head>
<base href="http://www.sample.com/">
</head>
Depending upon the structure of your URLs, you may want to make sure that you're URL escaping backreferences. 根据您的URL的结构,您可能需要确保您的URL转义了反向引用。 Check out https://httpd.apache.org/docs/trunk/rewrite/flags.html
查看https://httpd.apache.org/docs/trunk/rewrite/flags.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.