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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.