Apache RewriteRule: bad flag delimiters

左心房为你撑大大i 提交于 2019-12-24 17:50:01

问题


This is my .htaccess file

# Redirect every request to index.php
RewriteBase /
RewriteEngine on 
RewriteRule .* to public/index.php

And i'm receiving the following error in the error.log:

RewriteRule: bad flag delimiters

What's wrong with the .htaccess file? (I just started stying mod_rewrite module).

Edit: the .htaccess file is in the site's root.


回答1:


Remove "to":

RewriteRule .* public/index.php

Documentation




回答2:


AFAIK, you don't need a "to" in the rewrite rule. just delete that word and it should be ok.

RewriteRule .* public/index.php

The docs go into this in depth.




回答3:


The other ones are right, but don't forget to keep what's after the ? in the URL, it's the QSA flag, like this:

# Redirect every request to index.php
RewriteBase /
RewriteEngine on 
RewriteRule .* public/index.php [QSA]


来源:https://stackoverflow.com/questions/8717969/apache-rewriterule-bad-flag-delimiters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!