简体   繁体   中英

HTAccess Redirect Rule Needed

I'm looking to rewrite my url's but I can't seem to get the code right

I need to have:

mydomain.com/dj

become:

 mydomain.com/services.php?q=dj

but I still want it to show up as

 mydomain.com/dj

this will be the case for dj, photo, video, etc

Any help would be great!

Stop downvoting me! I have searched all over and not found how to do this

I know how to do:

Redirect /page.php?id=3  http://mydomain.site/page/3

but I need it to go the other way around

You can use the following Rule in your Root/.htaccess :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /services.php?q=$1 [QSA,NC,L]

This will rewrite "example.com/foo" to "example.com/service.php?q=foo".

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