简体   繁体   中英

Rewrite domain, but still use index.php

Current code to use index.php for all urls :

RewriteRule ^(.*)$ ./index.php

But for one special case, I want to make url

http://domain.com/s/this_changes to call actually http://domain.com/steps/step/this_changes .

I tried adding :

RewriteRule ^./s/$ ./steps/step/$1 , but it gives an error 500 .

Try this:

RewriteEngine On
RewriteRule ^s/(.+)$ /steps/step/$1 [L]

Another way you could do it is to route all your URIs through index.php, and create a function for each one.

RewriteRule ^s/this_changes$ steps/step/this_changes

if it is that simple or

RewriteRule ^(.*)/(.*)$ steps/$1/$2

And your specific code would work like this

RewriteRule ^s/(.*)/?$ ./steps/step/$1

The (.*) is referenced in your $1 in the second part of your code.

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