为什么这个漂亮的网址.htaccess不起作用?

时间:2018-05-02 01:52:01

标签: .htaccess url redirect

我正在尝试使用.htaccess文件来完善我的网址。我尝试了一些不同的规则,但网站一直在崩溃。我已经包含了将公用文件夹添加到根目录的代码,因为即使它有效,我怀疑它可能会影响后面的代码,但这并不起作用。

# Turn Rewrite Engine On
RewriteEngine on

# Make /public/ part of root
RewriteCond %{HTTP_HOST} ^mysite.dev$ [NC,OR]
RewriteCond %{HTTP_HOST} ^mysite.dev$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

# Rewrite for terms-and-conditions.php
RewriteRule ^legal$ terms-and-conditions.php [NC,L]

# NC makes the rule non case sensitive
# L makes this the last rule that this specific condition will match
# $ in the regular expression makes the matching stop so that "legalblah" will not work

# Rewrite for package.php?feature=something
RewriteRule ^package/([0-9a-zA-Z]+)$ package.php?feature=$1 [NC,L]

0 个答案:

没有答案