简体   繁体   中英

ReWrite rule not working with two parametrs

im quite new to rewrite rules. I can manage with one variable and thats it.

I have webpage Where the rewriterule is:

RewriteCond %{HTTP_HOST} ^www\.someserver\.com$
RewriteRule ^/?$ "http\:\/\/someserver\.com\/" [R=301,L]

RewriteRule ^(\d+)*$ ./index.php?comp=$1
RewriteRule ^(\d+)*/$ ./index.php?comp=$1

And it all work fine as it should. But now as i want 1 more variable into URL i cant get it to work.

Right now the $1 is only numbers.

someserver.com/1554886

But i want two variable.

someserver.com/1554886-SOMENAME-WHATEVER-WORD-AND-HOW-MANY

But it wont show.

i tried smth like this:

RewriteRule ^([^-]*)-([^-]*)$ ./index.php?comp=$1&string=$2 [L]

How do i get it to work? Do i have to make some changes in the php side as well? everything what comes after the number part of the URL is there only for SEO, the number is Unique

You need one more rule to handle two parameters:

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^www\.(someserver\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

RewriteRule ^(\d+)/?$ index.php?comp=$1 [L,QSA]

RewriteRule ^(\d+)-(.+)/?$ index.php?comp=$1&string=$2 [L,QSA]

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