How To Troubleshoot mod_rewrite in Apache Linux Server Guide

this tutorial guide will show you how to troubleshoot a problem with apache mod_rewrite for your page urls

I was migrating a website from one server to another. When I uploaded all the files to the new server, the mod_rewrite was not working right. I was trying to mascarade my dynamic PHP urls into static urls as .html , but i kept getting a 404 error. I will help you troubleshoot if you are having the same fraustration as I was. Please note this troubleshooting guide tutorial works well and was tested with Linux Fedora Core 4, it may not be the same for other Linux Distributions.

First make sure you have done this:

How to Enable mod_rewrite in Apache Server [click on the link to see thread ]

after you have made sure that your apache mod_rewrite is enabled, do this:

[ WARNING: make a backup copy before you begin ]

1. open your httpd.conf file [ /etc/httpd/conf/httpd.conf ] if you dont know how to, executre this command in the shell: nano /etc/httpd/conf/httpd.conf

2. find and edit the following line in the httpd.conf file:

FROM:

 

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None


TO:

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride ALL

- Basicaly I am only changing "None" to "All" in the "AllowOveride"

- You can now edit the file with Linux nano editor, after you have edited hit control + x then it will ask you to save, say yes by typing the letter y then hit return. Next it will display the file name to confirm save as, in this case it will be httpd.conf, just hit return to save and go to next step

Step 3. After you have edited and saved the httpd.conf file, restart apache with this command:

/etc/init.d/httpd restart

step 4. After you have executed the above command, you will see httpd (apache) stop and then it will restart. it should give you an "OK" if you get a "FAIL", you have have done something wrong. If you are not sure what you did wrong, go back to the back-up file from from step 1 that you made before you began this troubleshooting guide. If you got OK, Congratulations! now test your mod_rewrite (.htaccess) and it should work. if it doesn't, you can post your trouble here to see if we can give you an answer.

Hope this helps

8816 - Sat Feb 02, 2013 22:11:24