0

I have the following code in the my .htaccess file and the top Rewrite works fine the bottem one does not I know why but I dont kno how to fix it.

Its seeing RewriteRule ^([^/]*).html index.php?p=order&course_id=$1 [L] as the top rewrite command becuase of the hightlighed part and i dont want to put it in a dir

RewriteEngine on

RewriteRule ^([^/.]+).html index.php?p=$1 [L]

index.php?p=about_us 

RewriteRule ^([^/]+).html index.php?p=order&course_id=$1 [L]

 index.php?p=order&course_id=5 

Thank you,

1
  • Not sure I get this rught because LHS condition for both of your rules is same ^([^/]+).html ? Commented Jun 16, 2011 at 18:15

2 Answers 2

0

Can you give example urls that should match the pattern block and what you would like them to be rewritten to? That would be very helpful.

One thing I notice is that your first regexp you test if you match the pattern block with a + which means 1 or more times and the second one you check it with a * which means 0 or more so I don't think the second one will ever be called, although I am very new to regexps but it is just something I noticed.

These are very helpful resources for me:

http://www.webforgers.net/mod-rewrite/mod-rewrite-syntax.php

http://forum.modrewrite.com/

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

1 Comment

@Gully okay so you want domain.com/about_us to turn into domain.com/index.php?p=about_us I think but what about the second one?
0

From the example of the urls you would be using, this should work:

# http://website.com/about_us/ rewrites to /index.php?p=about_us RewriteRule ^([0-9a-z_-]+)/?$ index.php?p=$1 [NC,L] # http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12 RewriteRule ^order/([0-9]+)/?$ index.php?p=order&course_id=$1 [NC,L] 

The second Rewrite might be:

# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12 RewriteRule ^([0-9a-z_-]+)/([0-9]+)/?$ index.php?p=$1&course_id=$2 [NC,L] 

Depending on your page structure.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.