ejaboneta Posted January 24, 2011 Share Posted January 24, 2011 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 More sharing options...
ejaboneta Posted January 24, 2011 Author Share Posted January 24, 2011 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 Link to comment https://forums.phpfreaks.com/topic/225543-redirecting-instead-of-rewriting/#findComment-1164782 Share on other sites More sharing options...
strago Posted January 28, 2011 Share Posted January 28, 2011 Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/([^.]+)$ index.php?p=$1/$2 [L] or RewriteRule ^([^.]+)$ index.php?p=$1 [L] if you're going from com/index.php?p=Free-Quote to com/Free-Quote Link to comment https://forums.phpfreaks.com/topic/225543-redirecting-instead-of-rewriting/#findComment-1166310 Share on other sites More sharing options...
ejaboneta Posted January 28, 2011 Author Share Posted January 28, 2011 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] Link to comment https://forums.phpfreaks.com/topic/225543-redirecting-instead-of-rewriting/#findComment-1166380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.