【发布时间】:2021-03-04 01:06:18
【问题描述】:
我需要帮助在我的 .htaccess 文件中设置 RewriteRules。我需要首先检查任何现有文件,然后进行一些自定义重写,如果其中任何一个不匹配,请将其重写为 index.php。
我当前的.htaccess,位于文档根目录,文件如下:
RewriteEngine On
RewriteBase /
# Don't rewrite existing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Custom rewrites
# TODO: Don't know how to make these work
# RewriteRule ^/css/style\.css$ /css/style.css.php [L,NC,QSA]
# RewriteRule ^/js/config\.js$ /js/config.js.php [L,NC,QSA]
# RewriteRule ^/js/post\.js$ /js/post.js.php [L,NC,QSA]
# If any of the above don't match hand it to index.php
RewriteRule ^(.+)$ index.php [QSA,L]
php_value upload_max_filesize 10485760
php_value post_max_size 10485760
提前致谢!
【问题讨论】:
标签: regex apache .htaccess redirect url-rewriting