I have a web-site in the directory d:\www\mysite on my local computer. I installed WAMPServer and set up an alias directory mysite for my site.
So, for instance, http://localhost/mysite/static-resource.html correctly retrieves my file which is located in d:\www\mysite\static-resource.html.
My issue is with the URL rewriting in my .htaccess file:
RewriteEngine On
RewriteRule ^articles/(\d+) ./article.php?id=$1
When I try to access http://localhost/mysite/articles/1, I get this response:
Not Found
The requested URL /www/mysite/article.php was not found on this
server.
I can confirm that there exists a article.php file at d:\www\mysite\article.php.
In the past, I had the root of my site (d:\www\mysite) set up as the DocumentRoot of the Apache server (instead of c:\wamp\www which is the default), and in that scenario, my URL rewriting worked, so my current issue must be related to the fact that my site is “behind” an alias directory.
The contents of my mysite.conf file:
Alias /mysite/ "d:/www/mysite/"
<Directory "d:/www/mysite/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
I do not see a RewriteBase in your rewrite rules.
In your
.htaccess, add aRewriteBaserule.RewriteBase has to have
/mysite/because of yourAlias /mysite/ "d:/www/mysite/"If just
http://localhost/mysiteis accessed, It should return anot found on this server.If you do not want this to happen, add another alias along with the above like this:
or
Just this:
why a RewriteBase? from RewriteBase Directive Apache Docs:
Example from RewriteBase Directive Apache Docs: