Jump to content

Redirecting instead of rewriting.


ejaboneta

Recommended Posts

I've done mod_rewrite a few times before, but this time apache redirects the page instead rewriting as I would expect it to. I'm using a godaddy virtual dedicated server so I have access to apache directly.

 

I do this:

RewriteEngine On
RewriteRule ^([:\+.\)\(a-zA-Z0-9\_-]+)\/([:\+.\)\(a-zA-Z0-9\_-]+)$ http://domain.com/index.php?p=$1/$2 [L]

 

and when I go to url "http://domain.com/page/one", the url changes to "http://domain.com/?p=page/one" instead of staying the clean url. Am I doing something wrong?

Link to comment
https://forums.phpfreaks.com/topic/225543-redirecting-instead-of-rewriting/
Share on other sites

I'd just like to say that after spending a couple hours going through this forum... it's absolutely amazing how many times "how can I change http://mysite.com/index.php?id=343 to look like http://mysite.com/343/page-title?" is asked.... Can we find a good one and sticky it? It's just a little frustrating that I can't find anything relating to my problem... My urls go where they are supposed to but the url is changed back to an unclean url... for example:

 

http://freemedigapquote.com/page/one

Yes, that works, but it doesn't solve my problem. I fixed it by adding [P]. For some reason my server defaulted to redirect rather than mask the url... So a user would go to 'com/Free-Quote' but they would be redirected to 'com/index.php?p=Free-Quote'(showing in the address box)...

 

I add the [P] and it works now without redirecting

 

Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^([^.]+)/([^.]+)$ index.php?p=$1/$2 [L,P]

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.