RewriteRule ^index.html$ index.php
RewriteRule ^realisations.html$ realisations.php
RewriteRule ^roofing-services-montreal/roofing.html$ roofing.php
I'm new to mod_rewrite, and it's either my server doesn't support the module or I'm doing something wrong.
Should the code above work properly if uploaded to www.website.com/.htaccess ?
Basically I'm trying to change specific .php pages to .html, and give some pages a fake sub-directory extension, will this work?
Thank you very much in advance.
If this is Apache 2.x, then yes it should work and indeed, a .htaccess file in the root of your website is correct as well.
If it is Apache 1.x --highly unlikely since I don't think anyone uses that anymore-- it will not work, you'd need to change every ^ with ^/
Also, you need to escape dots in the filename, like this
RewriteRule ^index<font color='"#FF0000"'>\\</font>.html$ index.php
RewriteRule ^realisations<font color='"#FF0000"'>\\</font>.html$ realisations.php
RewriteRule ^roofing-services-montreal/roofing<font color='"#FF0000"'>\\</font>.html$ roofing.php
Have you checked if your Apache server has mod_rewrite loaded? This needs to be loaded in the apache2,conf. Typically in Debian based distributions in root->etc->apache2->mods-enabled you need a rewrite.load like
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
. If you have this in there or in your main apache2.conf file and apache starts without errors then it should be loaded.
As you are using php you can also create a php page that has only:
or somewhere in one of the pages that you are trying to have a redirect to occur use:
print_r</font><font color='#007700'>(</font><font color='#0000BB'>get_loaded_extensions</font><font color='#007700'>());
Good thought but mod_rewrite code on a server where it's not loaded and enabled would generate syntax errors which cause 500 errors to be sent, i.e., it's enabled.
This topic is now closed. New replies are no longer allowed.