Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question

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

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

add comment

1 Answer 1

up vote 2 down vote accepted
  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]
share|improve this answer
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"?) –  w3d Nov 18 '13 at 21:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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