Jump to content

mod_rewrite help


tgeorge06

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/218731-mod_rewrite-help/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/218731-mod_rewrite-help/#findComment-1134635
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.