Reputation:
I'm facing a quite strange behaviour of my .htaccess. Whenever I try to access a link rewritten by mod_rewrite, my .htaccess is refering to the root and not the subdirectory I'm working in. My folder structure looks like that:
htdocs/
blog6/
.htaccess
My .htaccess looks like that:
Options +FollowSymLinks -MultiViews
ErrorDocument 401 /core/error/401.php
ErrorDocument 403 /core/error/403.php
ErrorDocument 404 /core/error/404.php
ErrorDocument 500 /core/error/500.html
RewriteEngine on
RewriteBase /blog6/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?page=$1 [L]
But whenever I try to access a file through a rewritten url, I get a 404 error and the log says:
C:/xampp/htdocs/index.php' not found or unable to stat
So it seems like my .htaccess wants to access the file in the htdocs instead of using the subdirectory. When I write /blog6
in my rewriteRule, everything works fine, but why RewriteBase isn't working properly? If it's important, I'm using <base>
in my html
Upvotes: 2
Views: 185
Reputation: 784998
RewriteBase
works only if you provide relative URL in target of RewriteRule
so change your code to:
Options +FollowSymLinks -MultiViews
ErrorDocument 401 /core/error/401.php
ErrorDocument 403 /core/error/403.php
ErrorDocument 404 /core/error/404.php
ErrorDocument 500 /core/error/500.html
RewriteEngine on
RewriteBase /blog6/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA]
Upvotes: 0