Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.