I am trying to use htaccess Rewrite Rules. I need
http://www.sitename.com/variable/upload.php
to map to
http://sitename.com/upload.php?slug=variable
http://www.sitename.com/variable/gallery.php
to map to
http://sitename.com/gallery.php?slug=variable
http://www.sitename.com/variable/
to map to http://sitename.com/home.php?slug=variable
For the third part I have:
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+) home.php?slug=$1 [L]
But Now http://www.sitename.com/variable/upload.php
also map to http://sitename.com/home.php?slug=variable
How can i do this ?
Have your rules like this:
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ $2?slug=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ home.php?slug=$1 [L,QSA]
ie handle 2 slashes rule before you rewrite to home.php
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.