Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug htaccess rewrite script

Tags:

I was wondering how to create and debug this kind of script that can become a bit of headache if you are not used to write them (like me).

Do you use tool to create them?

Any tips to debug what's going on instead of just create a local structure and see what's happening in the browser?

like image 479
Soundstep Avatar asked Oct 12 '11 09:10

Soundstep


People also ask

How do I debug .htaccess file?

To test your htaccess rewrite rules, simply fill in the url that you're applying the rules to, place the contents of your htaccess on the larger input area and press "Check Now" button. Thanks for the pointer to this tool, which I found the most direct way to debug my problem.

How do I know if htaccess rewrite is working?

Save the file and type the URL yoursite.com/foobar/ . If the reditect works and the URL gets redireted to the homepage of example.com then it's clear that your htaccess is working and being read by your Apache server. If it still doesn't work then the problem might be that your hosting provider has not enabled it.

What is rewrite rule in htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.

What does IfModule Mod_rewrite C mean?

The <IfModule mod_rewrite. c>... </IfModule> block ensures that everything contained within that block is taken only into account if the mod_rewrite module is loaded. Otherwise you will either face a server error or all requests for URL rewriting will be ignored.


1 Answers

Note to readers: the old answer doesn't work anymore.

As of version 2.4, Apache no longer allows the RewriteLogLevel and RewriteLog directives. Now they're all bundled with the single LogLevel directive (see Log Files documentation), which supports module-specific log levels with prefixes and trace[1-8] constants. To set the highest level of logging specifically for the rewrite module, you now use the following:

LogLevel warn rewrite:trace8 
like image 91
Joshua Honig Avatar answered Oct 16 '22 20:10

Joshua Honig