Wiedmann wrote:With the above config, you can access the file "P:\website\upload\slush\sub1\test.html" without any problems with the URI "http://localhost/slush/sub2/test.html". (and that was the question)
This was not the original question of the OP, I did point out the difference in my last post but he did change it in a later post.
Your URI
"http://localhost/slush/sub2/test.html" <this is not a rewritable URI as it is the correct URI to go to the test.html with or without a .htaccess rewrite rule.
This would be a true test of the .htaccess rewrite rule which is as the OP wanted in the first place:
http://localhost/sub/test.htmlThat URI with the .htaccess rewrite rule loads the test.html in the sub2 folder as expected.
The fault has been in the Alias, which I removed for this test and no problems.
If
slush is in the URI then the Alias redirects the request to the doc root and there is no
sub2 folder in the doc root, it is in the
slush folder - the conflict starts here.
The Alias is parsed first followed by the .htaccess file so the Alias has passed the URI with a slush in it to doc root then the .htaccess takes the URI and tries to rewrite the URI to the sub2 folder which is not in the doc root, consequence is a file not found.
So now we have:
.htaccess in C:\xampp1\htdocsRewriteEngine On
RewriteBase /slush
RewriteRule ^sub/(.*)$ sub2/$1
TreeC:\xampp1\htdocs\slush\sub2\test.html
URIhttp://localhost/sub/test.htmlLOG
No error
Wiedmann wrote:Sorry you are right (it's was really to late...),
No need for apologies as we can all err when it is way past our bed time.
Wiedmann wrote:the sentence should be (and that is the rule doing):
With the above config, you can access the file "P:\website\upload\slush\sub2\test.html" without any problems with the URI "http://localhost/slush/sub/test.html".
Your URI
http://localhost/slush/sub/test.htmlGives a 404 error.
http://localhost/sub/test.htmlDoes not give a 404 error.
Izzy wrote:Did you test your config before posting
Wiedmann wrote:Sure. (The post was a copy 'n paste from my working config)
Not a true test because as far as I can tell you did not include the Alias in the httpd.conf file into the equation, which would have produced the 404 errors.
This is the erroneous Alias and when removed the rule works, when it is inserted the URIs return error 404:
- Code: Select all
Alias /slush "C:/xampp1/htdocs"
<Directory "C:/xampp1/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
@Seymour Clufley
At least for now, please use either an Alias or a rewrite rule but not both especially the above Alias directive and try and confirm exactly what you want to do and how you want to access your files.
Thanks.