0

There are two kind of pages -

  1. www.mysite.com/about.php
  2. www.mysite.com/winners.php?y=2008

I want to make them like - 1. www.mysite.com/about 2. www.mysite.com/winners/2008

my htaccess is like -

RewriteEngine On
#removing .php ext(type-1)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

#for type-2 (with parameter)
RewriteRule winners/([0-9]+)/?$ winners.php?y=$1 [L]
RewriteRule winning-photograph/([0-9]+)/?$ winning-photograph.php?y=$1 [L]
RewriteRule award-giving/([0-9]+)/?$ award-giving.php?y=$1 [L]
RewriteRule album-launch/([0-9]+)/?$ album-launch.php?y=$1 [L]
RewriteRule district-fest/([0-9]+)/?$ district-fest.php?y=$1 [L]
RewriteRule lifetime-achievement-awards/([0-9]+)/?$ lifetime-achievement-awards.php?y=$1 [L]
RewriteRule critics-award-for-tv/([0-9]+)/?$ critics-award-for-tv.php?y=$1 [L]
RewriteRule photography-book/([0-9]+)/?$ photography-book.php?y=$1 [L]

The two section of this htaccess are not working at the same time. what can I do? also - is there a way to simplify the 2nd section?

5
  • Do you want to hide or encode the url? Commented Mar 13, 2011 at 8:00
  • @Ankit do you mean clean URLs? @Emrul Hasan you can try to replace [L] with [L,QSA] Commented Mar 13, 2011 at 8:01
  • In what way are they not working? Commented Mar 13, 2011 at 8:02
  • Instead of clean url you can encode url feature. Commented Mar 13, 2011 at 8:04
  • tell some more about clean url Commented Mar 13, 2011 at 8:44

1 Answer 1

2

Your first RewriteRule is basically preventing all the other rules from executing. It does that rule for both types of your URLs, then the [L] flag stops it from evaluating the other rules.

I would say put that rule at the very end. Do all the more-specific ones first, then have that as a generic one for all other cases, only to be evaluated if the rest of the rules didn't match the current URL.

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.