开发者

Why is modrewrite using my site's full path?

I wanted to redirect all non .html links to html links, such as domai开发者_JS百科n.com/hey to domain.com/hey.html so I used the following rules

RewriteCond %{REQUEST_URI} !^\.html$
RewriteRule ^([a-zA-Z\+]+)$ $1\.html [R=301,L,NE]

However the redirect happens like this:

http://domain.com/what+there -> http://domain.com/home/user/public_html/what+there.html

Why is this?


looks like you are using your RewriteRule in a per-directory context (.htaccess or <Directory>). in this case,

[...] the per-directory prefix (in your case /home/user/public_html) is automatically removed for the RewriteRule pattern matching and automatically added after any relative (not starting with a slash or protocol name) substitution encounters the end of a rule set.

to avoid this, use RewriteBase, like so:

RewriteBase   /

also note the other additional complexity items for per-directory rewrites.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜