megashape — 2012-06-12T11:42:51-04:00 — #1
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.
megashape — 2012-06-12T15:51:41-04:00 — #2
scallioxtx — 2012-06-13T03:35:53-04:00 — #3
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
serverstorm — 2012-06-13T11:12:45-04:00 — #4
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'>());
dklynn — 2012-06-14T00:08:40-04:00 — #5
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.