tgeorge06 Posted November 15, 2010 Share Posted November 15, 2010 alright, so i've been messing with mod_rewrite for the past few days trying to figure it out on my own and it isn't working out exactly as I had planned. Firstly, I thought mod_rewrite just rewrote the url's based on the regex's and what not that is declared, but I was wrong. So I now understand that when im forming my html links instead of doing products.php?id=$id it should be example.com/products/$id.html and mod_rewrite tells the script that i'm actually saying example.com/products.php?id=$id. At least thats what I think i know as of now. So here is where i'm at, I wrote my url as follows: http://footballbookends.com/products/Football_and_Baseball_Bookends-14238.html and my RewriteRule(inside httpd.conf) as follows: <Directory "/var/apanel/www"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^products/([^/]+)-([^/]+)\.html$ products.php?productName=$1&id=$2 </IfModule> </Directory> Now i'm not sure if it matters but, /var/apanel/www is the base folder for all of our websites so footballbookends.com lives inside /var/apanel/www What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/218731-mod_rewrite-help/ Share on other sites More sharing options...
tgeorge06 Posted November 15, 2010 Author Share Posted November 15, 2010 Well the rewrite works if i put it under the Vhost block, but i'm trying to do this globally for all 1,500 websites that is on the server with this method of products. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/218731-mod_rewrite-help/#findComment-1134587 Share on other sites More sharing options...
tgeorge06 Posted November 15, 2010 Author Share Posted November 15, 2010 I edited the rewrite code some more and i put this code block inside of httpd.conf, not under a directory or anything. I don't think im understanding the correct path's for this mod_rewrite, but would that not be an absolute path to the page i want/need to go to? <IfModule mod_rewrite.c> RewriteEngine On RewriteRule http://%{HTTP_HOST}/products/([^/]+)-([0-9]+).html http://%{HTTP_HOST}/products.php?productName=$1&id=$2 </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/218731-mod_rewrite-help/#findComment-1134635 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.