0

I'm trying to make

domain.com/notalone/viewpost/5/ 

act as

domain.com/notalone/viewpost.php?id=5

My current .htaccess is this:

RewriteEngine On

RewriteRule ^notalone/viewpost/([0-9]+)/?$ /viewpost.php?id=$1 [QSA]

Currently, the page loads properly when you visit /notalone/viewpost/5/ but it does not pass $_GET['id']

Things I've Tried:

  • Adding Options -Multiviews ---> Results in a 404
  • Using Rewritebase / ---> No effect
  • RewriteRule ^viewpost/([0-9]+)/?$ /viewpost.php?id=$1 [QSA] ---> No effect
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Tyler Roper
  • 21,445
  • 6
  • 33
  • 56
  • There might be a challenge in combining `[QSA]` and `?id=$1`. You could use: `RewriteRule ^viewpost/([0-9]+)/?$ /viewpost.php?id=$1&%{QUERY_STRING}` without the QSA – Bjørne Malmanger Feb 01 '13 at 21:33
  • If you hardcode the $1 to some string like 'blah' and does it come through? It could be your $1 variable is not capturing what you think it is. – Eric Leschinski Feb 01 '13 at 21:33
  • No luck. Here's a snippet of the server vars `["QUERY_STRING"]=> string(0) "" ["REQUEST_URI"]=> string(21) "/notalone/viewpost/5/" ` – Tyler Roper Feb 01 '13 at 21:35
  • @EricLeschinski Changed it to `blah` and `5`, neither of which worked. – Tyler Roper Feb 01 '13 at 21:36

2 Answers2

0

Try adding the pass-through flag, like so:

RewriteRule ^notalone/viewpost/([0-9]+)/?$ /viewpost.php?id=$1 [QSA,PT]

'PT' adjusts the internal URL so later handlers see the result of the mod_rewrite work, rather than the original URL.

Dave S.
  • 6,349
  • 31
  • 33
0

Solved the issue. The problem was evidently an issue with my directories, because when I moved the website to it's own host (its own root directory instead of the notalone subdirectory), everything seemed to work like a charm.

Tyler Roper
  • 21,445
  • 6
  • 33
  • 56