Jagarm Posted March 12, 2009 Share Posted March 12, 2009 I was wondering if it's possible to redirect if user enters http://beta.berwari.net/index.php?display=contact to http://beta.berwari.net/contact Thanks Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/ Share on other sites More sharing options...
trq Posted March 12, 2009 Share Posted March 12, 2009 I think you phrased your question incorrectly. Don't you want to rewrite the url http://beta.berwari.net/contact to point to http://beta.berwari.net/index.php?display=contact ? Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-782923 Share on other sites More sharing options...
Jagarm Posted March 12, 2009 Author Share Posted March 12, 2009 Actually I'm correct, see some of my links are in this format http://beta.berwari.net/index.php?display=contact and when links like those are clicked, I want in the address bar to be http://beta.berwari.net/contact Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-782934 Share on other sites More sharing options...
corbin Posted March 12, 2009 Share Posted March 12, 2009 In the sense that I think you mean, thorpe was correct. You probably want something like: RewriteCond RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/?$ /index.php?display=$1 Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-783258 Share on other sites More sharing options...
Jagarm Posted March 12, 2009 Author Share Posted March 12, 2009 I apologize for the confusion. The following is my .htaccess Options +FollowSymlinks RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^/\.]+)/?$ /index.php?display=$1 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?display=$1&action=$2 [L] Now let's say I have this link now if you mouse over you will see is in the ugly format, and that is what it will display in the address bar. My question here is, is there any way or flag that can display http://beta.berwari.net/contact instead of http://beta.berwari.net/index.php?display=contact? I am able to convert from http://beta.berwari.net/contact to http://beta.berwari.net/index.php?display=contact but that is not what i want is the other way around. I don't want the user to see http://beta.berwari.net/index.php?display=contact in the address bar, even if a link is in that format I want to convert it into the proper format that is www.domain.com/page_ :police:name Sorry the site is restricted to certain sites only due to work in progress. I hope I have made it clear and if not please let me know. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-783310 Share on other sites More sharing options...
corbin Posted March 12, 2009 Share Posted March 12, 2009 You can change what will be in the address bar by using a 301 redirect (or a 302), but you cannot change the content of a page without... changing the content of a page. In other words, you would have to change all index.php?... links to /..... To have your webserver redirect index.php?display=contact to /contact, you could do something like: RewriteRule ^index.php?display=([^&]+)$ /$1/ [R=301,L] Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-783314 Share on other sites More sharing options...
Jagarm Posted March 12, 2009 Author Share Posted March 12, 2009 Now I get it, really appreciate for the explanation Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-783344 Share on other sites More sharing options...
corbin Posted March 12, 2009 Share Posted March 12, 2009 ;p Quote Link to comment https://forums.phpfreaks.com/topic/149103-solved-mod-rewrite-redirect/#findComment-783395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.