简体   繁体   中英

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

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! How can i solve that?

Thanks!

You need to set <base> tag into your head and put your domain name into 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. Check out https://httpd.apache.org/docs/trunk/rewrite/flags.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM