Htaccess RewriteRule

前端 未结 1 1389
慢半拍i
慢半拍i 2020-12-22 01:42

After asking this question Htaccess URLRewrite to another map That works great, but now i want to add an extra \'map\', but that don\'t work.

My .htaccess file now:

相关标签:
1条回答
  • 2020-12-22 02:06

    You need to duplicate the 2 conditions again. RewriteCond's are only applied to the immediately following RewriteRule, so you need to duplicate the conditions if they are to be applied to more than one rule:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^werknemer/([^/]+)/?$ werknemer/$1.php [L,QSA,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^klanten/([^/]+)/?$ klanten/$1.php [L,QSA,NC]
    

    Maybe you need it for your last rule as well:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^/(.*?)/?$
    RewriteCond %{DOCUMENT_ROOT}/%1.php -f
    RewriteRule ^ /%1.php [L]
    

    That checks if a trailing slash exists, and to remove it before seeing if adding the php to the end produces an existing file.

    0 讨论(0)
提交回复
热议问题