purencool Posted August 3, 2011 Share Posted August 3, 2011 I am trying to rewrite a url and not having much luck. the current urls is, http://work/cms/index.php?p=contact what I would like is http://work/cms/contact My htaccess file has the following rule Options +FollowSymlinks RewriteEngine on RewriteRule ^/([^/]+)/.php /index.php?p=$1 [NC] But it is not working can anyone give me some idea what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/ Share on other sites More sharing options...
trq Posted August 3, 2011 Share Posted August 3, 2011 That rule is nothing like what you need. Can I suggest you find some tutorials? It's a pretty basic rule you need but your not going to learn anything if we just hand it to you. Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/#findComment-1251010 Share on other sites More sharing options...
purencool Posted August 3, 2011 Author Share Posted August 3, 2011 Ok thanks how can I test the Options +FollowSymlinks RewriteEngine on is working? Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/#findComment-1251011 Share on other sites More sharing options...
trq Posted August 3, 2011 Share Posted August 3, 2011 You could do so using the rule you currently have. Just place.... if (isset($_GET['p'])) { echo $_GET['p']; } in your index.php file and go to http://yourdomain.com/foo.php If it echo's foo it's working. Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/#findComment-1251013 Share on other sites More sharing options...
purencool Posted August 3, 2011 Author Share Posted August 3, 2011 it works if I type http://work/cms/contact. But it is not rewriting the url do I have the correct assumption. Options +FollowSymlinks RewriteEngine on RewriteRule ^/([^/]+)/.php /index.php?p=$1 [NC] Is this happening because of my expression or do I need to look for more. I don't want the answer I will work it out I but some direction would be great ^/([^/]+)/.php Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/#findComment-1251018 Share on other sites More sharing options...
purencool Posted August 3, 2011 Author Share Posted August 3, 2011 ok worked it out, RewriteRule ^([^/\.]+)/?$ index.php?p=$1 [L] but the links in the app were set to index.php?p=foo so when clicked it was displaying the link. When these were changed it work perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/243652-rewrite/#findComment-1251027 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.