Question on debugging with mod_rewrite

Let's say my simple .htaccess file looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^login/*$ public/login.php [L]

Open in new window

To my understanding, if I used the URL of, it should redirect to mySite/public/login.php. In my browser, it would say (which is expected), but I'm getting an error saying "Object not found. The requested URL was not found on this server.", so it's evident to me that Apache couldn't find the page I'm asking it to redirect to.

However, in order for me to troubleshoot this, I need to know what URL Apache is trying to redirect to. How can I see what URL Apache is *actually* using?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your code appears to be correct.  I tested it in my setup.  My concern is with the RewriteBase line.  Is / the correct path to the public folder?  The object not found may be because the public folder wasn't found in the directory that / points to.

If the public folder is within another subfolder, you would need to specify that in the line.  So if your webroot was / and the public folder was inside another folder called subfolder, then:
RewriteBase /subfolder/

Open in new window

Also, have you gone directly to the URL of /public/login.php to ensure that page loads normally?
elepilAuthor Commented:
To bigeven2002.

I think I was able to figure it out .. this time. My application's full path is:


And in that is the 'public' folder (i.e., C:\xampp\htdocs\myApp\public\login.php). But still, I know this won't be the last path-related issue I'll encounter, and I really want to know how to debug mod_rewrite issues like this. It would've been much easier for me to troubleshoot if I only knew what URL Apache was using when it issued the error.

Do you know a way of displaying the exact URL Apache is issuing?
Not sure of the exact answer on how displaying the URL.  Do you mean to review that in a log file which URL is being parsed when the /login is requested?

This may be a long shot, but you can try adding the lines below to your .htaccess file.  This may result in 500 error though.  Change the log path to the rewrite.log location on your system.

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3

Open in new window

If your apache version is >= 2.4, then you might also need this line:
LogLevel alert rewrite:trace6

Open in new window

Or you can also try adding it to the virtual host file if that is accessible in xampp (change the path again)
<VirtualHost *:80>
  # ...

  RewriteLogLevel 8
  RewriteLog /var/log/apache2/rewrite.log

  # ...

Open in new window

I wasn't able to fully test this so I don't know if it will work or not.  But theoretically, this will put the URL being parsed in the log file for debugging purposes which might give you what you're looking for.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Also, check in your httpd.conf file at the end of it is this listed?
<IfModule mod_rewrite.c>
RewriteEngine On
LogLevel warn mod_rewrite.c:trace4

Open in new window

So I think this will output the data to c:\xampp\apache\logs\rewrite.log, or wherever the error.log is listed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
elepilAuthor Commented:
To bigeven2002.

RewriteLog "/var/log/apache2/rewrite.log does not work in .htaccess file. Do you know what file name contains the <VirtualHost *:80> is? I may have to do it in one of the config files.
elepilAuthor Commented:
Once again, thank you for your help, bigeven2002!
I honestly don't know which file has the virtual host setting, sorry.  I figured that might not work in htaccess but thought worth a try.  Let's skip the htaccess and virtualhost files and try the entry in the httpd.conf file above.
Glad I could help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.