Cbas Posted April 11, 2013 Share Posted April 11, 2013 I have this website coded in php: http://iioengine.com/ MyBB is installed in a subfolder: http://iioengine.com/forums/, it uses an htaccess file to remove the php extension from its page URLs. As an example, this link works: http://iioengine.com/forums/Forum-Box2D I would like to remove the URL extensions from all the non-MyBB parts of my website - to make this page: http://iioengine.com/demos.php, accessible from this link: http://iioengine.com/demos I thought this would be straightforward, but every .htaccess file I have implemented just results in 404 pages for all queries. Here is what I have now: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d </IfModule> It gives me 404 pages for non-.php queries, but I found that if I add this line: RewriteRule . /index.php [L] all non-'.php' requests get forwarded to the homepage... So mod_rewrite is definitely enabled, it's just not working right. Anyone know what the issue could be? If I can get this working, I also need some rules to cut off the extension even if it is in the query (since all of my hyperlinks use extensions). what do I need in my htaccess file to remove the file extension from the URL in all cases? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/276802-unable-to-use-htaccess-for-mod_rewrite/ Share on other sites More sharing options...
Solution Cbas Posted April 11, 2013 Author Solution Share Posted April 11, 2013 (edited) Figured it out though I don't know how. Nothing worked until I got rid of Wordpress's htaccess file in my primary root (iioengine is hosted in a subfolder of another site that uses WP). But then once I got everything working, I reactivated that htaccess file and everything still worked okay... Here is my final htaccess code for iioengine.com though: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## don't touch /forums URIs RewriteRule ^forums/ - [L,NC] ## hide .php extension snippet # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L] # To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [L] Edited April 11, 2013 by Cbas Quote Link to comment https://forums.phpfreaks.com/topic/276802-unable-to-use-htaccess-for-mod_rewrite/#findComment-1424221 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.