1

Trying to get SEO Friendly URLs to work for my website using the following htaccess:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^explore/(.*)$ index.php?page=explore&type=$1
RewriteRule ^(.*)$ index.php?page=$1

E.g. it should load /index.php?page=test for /test/ and /index.php?page=explore&type=1 for /explore/1.

However it's not working, does anyone know how I could get this to work?

migrated from stackoverflow.com Nov 18 '13 at 20:26

This question came from our site for professional and enthusiast programmers.

3
  1. You have RewriteEngine On missing
  2. RewriteCond are only applicable to next immediate RewriteRule

Try this code:

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^explore/(.*)$ index.php?page=explore&type=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
  • 2
    I would have said the QSA and NC flags should only be used if required. There does not appear to be anything in the question that suggests these would be needed. (This seems to be the result of an edit by "Community"?) – MrWhite Nov 18 '13 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.