Jump to content

Rewrite rule help


c_pattle

Recommended Posts

I've just enable mod_rewrite and tested it's all working fine and now I want to put it in actions.  I have a page called "review.php" that takes a review id which is a number.  So for example the url might be "review.php?review=123".  I want to change this so the url would be "review/123/" however I'm having some trouble with my rewrite rule. 

 

RewriteEngine on

RewriteRule ^review/([0-9]+)/?$ review.php?review=$1

 

When I type in "review/123/" I get taken to the review.php page but the review parameter doesn't seem to work.  Also when I get to the review.php page all of the css has been displayed.  Does anyone know why this is happened?

 

Thanks for any help. 

Link to comment
https://forums.phpfreaks.com/topic/236799-rewrite-rule-help/
Share on other sites

Add an [R] flag after the Rule. The browser will then show what URL it redirects to.

RewriteRule ^review/([0-9]+)/?$ review.php?review=$1 [R]

 

Your CSS isn't working because you're using relative paths, like


The browser is looking for it at /review/foo/bar.css instead of in /foo.

Use absolute paths:


Link to comment
https://forums.phpfreaks.com/topic/236799-rewrite-rule-help/#findComment-1217311
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.