【发布时间】:2013-05-03 20:35:33
【问题描述】:
这段代码真的让我很困惑,为什么会这样。如果我添加 [R=302,L] 然后我的链接就像我希望的那样完美。但如果我不添加它而我只有 [L] 它进入错误页面。 R和no R的区别不就是浏览器的地址栏有没有更新吗?
这是代码中的最后一行。我正在尝试进行内部/静默 mod_rewrite
我想要用户输入http://example.com 还是http://example.com/home/
我想要内部相同的网址http://example.com/home
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /
AddHandler application/x-httpd-php .css
AddHandler application/x-httpd-php .js
Options +Multiviews
RewriteEngine On
#NC not case sensitive
#L last rule don't process futher
#R 301 changes the url to what you want
#changes the host to make sure it has no www infront
RewriteCond %{HTTP_HOST} !^example\.host56\.com
RewriteRule ^(.*)$ http://example.host56.com [R=302,L]
#kills request with file extensions
RewriteCond %{THE_REQUEST} \.(php|jsp|html|jsp|asp)/?\ HTTP/
RewriteRule .* - [F]
#selects home
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\ HTTP/1.1$
RewriteRule ^.*$ home/ [L]
【问题讨论】:
-
那么是否有 /home/index.php 或 /home/index.html 文件实际处理请求?
-
它是 /home/index.php 并不重要。它应该会自动查找索引文件
标签: apache url mod-rewrite rewrite