1

I can't seem to get my .htaccess to work, I'm trying to rewrite all urls that aren't real files or folders to my index.php. The directory I'm in is /cms the rewrite only seems to work when I use this .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /cms/index.php [L]
</IfModule>

When I try and use the RewriteBase /cms/ and change the last line to . /index.php [L] like it's meant to be, the rewrite doesn't rewrite to localhost/cms/index.php and instead it gets rewritten to localhost/index.php

4

1 回答 1

1

尝试使用此版本:

RewriteEngine On
RewriteBase /cms/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

请注意,我使用index.php而不是/index.phpRewriteBase 来确保加载了相对 URI。

于 2013-05-01T06:24:34.210 回答