Jump to content

php mod_rewrite help


MDanz

Recommended Posts

i'm trying to get a clean url for my about page.

 

i want to change

 

http://www.example.com/about.php

 

to

 

http://www.example.com/about

 

i put my htaccess file as this

 

RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ about.php

 

it's not working though, i get the 404 not found error.

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

It sounds to me like there might be some confusion in this thread. If a request to example.com/about.php returns the file, then it sounds to me like public_html/example.com is the document root, not public_html as would be the standard (generally speaking i'd set that up as example.com/public_html). If this indeed the case and you are putting the .htaccess file outside the document root then it is not evening being parsed. One way to checkout would be to place the following in the .htaccess file...

 

RewriteEngine On
RewriteRule .* http://www.google.com [R=302,L]

 

... if you can request a page on your site without getting sent to google, the file isn't being parsed.

 

It seems to me, assuming I'm understanding your description correctly, that the .htaccess file should be in folder public_html/example.com/ along with your about.php file (this is essentially what wildteen88 said, just thought I'd clarify the reason).

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.