views:

40

answers:

2

I have been asked by our client to convert a site we created into SEO friendly url format. I've managed to crack a small way into this, but have hit a problem with having the same urls in the same folder.

I am trying to rewrite the following urls,

  1. /review/index.php?cid=intercasino
  2. /review/submit.php?cid=intercasino
  3. /review/index.php?cid=intercasino&page=2#reviews

I would like to get them to,

  1. /review/intercasino
  2. /submit-review/intercasino
  3. /review/intercasino/2#reviews

I've almost got it working using the following rule,

RewriteRule (submit-review)/(.*)$ review/submit.php?cid=$2 [L]
RewriteRule (^review)/(.*) review/index.php?cid=$2

The problem, you may already see, is that /submit-review rewrites to /review, which in turn gets rewritten to index.php, thus my review submission page is lost in place of my index page. I figured that putting [L] would prevent the second rule being called, but it seems that it rewrites both urls in two seperate passes. I've also tried [QSE], and [S=1]

I would rather not have to move my files into different folders to get the rewriting to work, as that just seems too much like bad practise. If anyone could give me some pointers on how to differentiate between these similar urls that would be great!

Thanks (Ref: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html)

A: 

What I would do, is make /submit-review/ post directly to itself (or a php file) then once submitted redirect from within the PHP file.

It can be hard to force htaccess to maintain post values whilst redirecting etc

Chris
I'm not really looking for redirection. Just to rewrite the urls.
DavidYell
A: 

My friend found a solution to this one.

RewriteRule review/submit.php - [L]

Will catch the first rewrite and then prevent the next one, worked a treat!

DavidYell
DavidYell