MDanz Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/ Share on other sites More sharing options...
gizmola Posted July 6, 2011 Share Posted July 6, 2011 The number 1 rule of regex, when you don't need a regex don't use a regex. RewriteRule ^about$ /about.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1238893 Share on other sites More sharing options...
MDanz Posted July 6, 2011 Author Share Posted July 6, 2011 ok i changed it and i typed http://www.example.com/about and i still get the 404 not found error RewriteEngine On RewriteBase / RewriteRule ^about$ /about.php [L] any idea what could be wrong? Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239173 Share on other sites More sharing options...
gizmola Posted July 6, 2011 Share Posted July 6, 2011 Is about.php in the root of your site? What is the document root and where are these mod rewrite rules? Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239194 Share on other sites More sharing options...
MDanz Posted July 6, 2011 Author Share Posted July 6, 2011 .htaccess file is in my public_html directory and about.php is in a folder in my public_html directory. Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239267 Share on other sites More sharing options...
gizmola Posted July 6, 2011 Share Posted July 6, 2011 So it's not in the root? It's in /somefolder/about.php? Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239275 Share on other sites More sharing options...
MDanz Posted July 6, 2011 Author Share Posted July 6, 2011 when i upload to the server the file is in public_html/example.com/about.php but on the domain address it is http://www.example.com/about.php Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239305 Share on other sites More sharing options...
wildteen88 Posted July 6, 2011 Share Posted July 6, 2011 Then you need to move the .htaccess file to public_html/example.com (same folder where about.php is) Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1239310 Share on other sites More sharing options...
cags Posted July 11, 2011 Share Posted July 11, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/241180-php-mod_rewrite-help/#findComment-1241139 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.