1

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 ?

1 Answer 1

1

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]

i.e. handle 2 slashes rule before you rewrite to home.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.