wright67uk Posted February 21, 2015 Share Posted February 21, 2015 I'm using an .htaccess file but it has no effect. I'm using godaddy for my hosting. #mod_rewrite #RewriteBase / #Fix Rewrite Options -Multiviews RewriteEngine on RewriteBase / Options +FollowSymLinks RewriteRule ^C_(.*)$ cat.php?type=$1 [L] RewriteRule ^P_(.*)$ product_info.php?name=$1 [L] Im trying to make it so if anyone were for an example to click on a link: 1pw.co.uk/product_info.php?name=namehere it would display in the browser as 1pw.co.uk/P_namehere at the moment everything is as it were before i even added the file. Where am i going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/ Share on other sites More sharing options...
Ch0cu3r Posted February 21, 2015 Share Posted February 21, 2015 This is no what mod_rewrite does! You have to change the links yourself to the new url format. Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506318 Share on other sites More sharing options...
wright67uk Posted February 21, 2015 Author Share Posted February 21, 2015 Can I change the file so that I can achieve this? Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506324 Share on other sites More sharing options...
Ch0cu3r Posted February 21, 2015 Share Posted February 21, 2015 Yes. You will need to edit your (HTML/PHP) code so your urls are in the new format. mod_rewrite does not edit the urls for you. mod_rewrite is used to map the fake urls site.com/P_namehere to your old url site.com/product_name.php?name=namehere Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506338 Share on other sites More sharing options...
wright67uk Posted February 21, 2015 Author Share Posted February 21, 2015 (edited) Ok thankyou, I understand how this works now. Can I change this so that instead of http://www.1pw.co.uk/C_Shrubs I can have http://www.1pw.co.uk/shrubs And instead of http://www.1pw.co.uk/P_AMELANCHIER%20CANADENSIS I can have http://www.1pw.co.uk/amalanchier_canadensis ? Thanks for your help on this :-) Edited February 21, 2015 by wright67uk Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506340 Share on other sites More sharing options...
Ch0cu3r Posted February 21, 2015 Share Posted February 21, 2015 Yes you can but then mod rewrite will not know which rewriterule will apply to those urls (for example it will not know that /shrubs should go to the rewriterule for cat.php or /amalanchier_canadensis should go to the rewriterule for product_info.php). It currently only knows which rewriterule applies due to the the C_ and P_ prefixes. If you don't like the C_ and P_ prefixes then maybe change your urls to something like site.com/category/shrubs site.com/product/amalanchier_canadensis Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506342 Share on other sites More sharing options...
wright67uk Posted February 21, 2015 Author Share Posted February 21, 2015 Ok great that would actually make a lot of sense for me to do that. Can you reccommend a good referance for when I come to make some new rules? Eg mod rewrite for beginners. Quote Link to comment https://forums.phpfreaks.com/topic/294767-mod-rewrite-has-no-effect/#findComment-1506345 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.