esoteric Posted July 19, 2011 Share Posted July 19, 2011 I'm trying to rename my urls in the address bar but for some reason it isn't taking any effect 4 pages i have tried on so far, the url in the web browser remains the same, am i missing something or is there something i need too change on my actual .php's? At the moment i haven't touched them and only uploaded the htaccess to my root directory. Options +FollowSymLinks RewriteEngine on RewriteRule ^/members/products/garden\.php$ category=garden [L] RewriteRule ^/members/products/home\.php$ category=home [L] RewriteRule ^/members/products/pets\.php$ category=pets [L] RewriteRule ^/members/products/gifts\.php$ category=gifts [L] Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/ Share on other sites More sharing options...
requinix Posted July 19, 2011 Share Posted July 19, 2011 1. The URL that RewriteRule works on doesn't normally start with a slash. But sometimes it does. I still don't know when that is. 2. I doubt you want to redirect to the address "/category=garden". Unless you want to restrict the rewriting to just those four categories, RewriteRule ^/?members/products/(\w+)\.php$ index.php?category=$1 [L] will handle all of them at once. The URL in your browser will not change. If you want it to then add an [R] flag to the Rule. Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1244926 Share on other sites More sharing options...
esoteric Posted July 19, 2011 Author Share Posted July 19, 2011 Sorry i poorly explained what i'm trying to achieve. What im trying to do is hide the file structure of my site so at the moment for example my 'garden' category is at www.website.com/members/products/garden.php. I just want that to appear as www.website.com/category=garden. It doesn't have to be exactly that, but that's easier for me to identify Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1244929 Share on other sites More sharing options...
requinix Posted July 20, 2011 Share Posted July 20, 2011 Oh. Then your Rule is backwards: the first bit is what you want to show and the second bit is what you want to hide. RewriteCond members/products/$1.php -f RewriteRule ^category=(\w+)$ members/products/$1.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1244947 Share on other sites More sharing options...
esoteric Posted July 20, 2011 Author Share Posted July 20, 2011 Thanks for the reply. It still appears to not work, the address isn't changing, unless im doing something wrong. Does the .htaccess file have to go in the same category? So lets say for the 'garden' link, do i have to put a .htaccess in the members/products/ folder, and same for all other folders, or is it just one file in the root directory? Do i need to alter my .php in any way? Appreciate your patience. Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1245020 Share on other sites More sharing options...
esoteric Posted July 20, 2011 Author Share Posted July 20, 2011 OK, i fixed it by changing my link in the php's. The new problem is it seems to have broken other scripts, i have a rating system on each page which no longer works when using the new links any idea what i need to look at to solve it? Im calling the script with <?php require('_drawrating.php'); ?> and on the page echo rating_bar('prod_num',''); It no longer seems to work, im not changing the name of _drawrating in the htaccess so im not sure whats up Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1245036 Share on other sites More sharing options...
requinix Posted July 20, 2011 Share Posted July 20, 2011 And what is "no longer works" supposed to mean? I can't see your code executing. I don't know what it's doing. Quote Link to comment https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/#findComment-1245226 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.