1
我有我的.htaccess文件安装如下。这是一个简单的概念,其中所有请求都转发到cgi-bin/controller.rb,除了那些请求/ images,/ css,/ javascripts或/ cgi-bin中的任何请求外,我还希望根被重定向到/ index/show,但那是错误的部分。它只是无限地重定向到/ index/showindex/showindex/show ...Htaccess RedirectMatch正确使用
任何人都可以解释为什么我的redirectmatch不起作用?
RedirectMatch permanent ^/$ /index/show
ErrorDocument 404 /404
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/images/ [NC]
RewriteCond %{REQUEST_URI} !^/css/ [NC]
RewriteCond %{REQUEST_URI} !^/javascripts/ [NC]
RewriteCond %{REQUEST_URI} !^/cgi-bin/ [NC]
RewriteRule (.*) /cgi-bin/controller.rb?%{QUERY_STRING}&page=$1 [L]
完美工作。你的回答帮助我更多地了解了htaccess文件的工作原理。谢谢。 – weexpectedTHIS
为什么要避免同时使用RedirectMatch和RewriteRule?它们是不同的模块,并且在请求流中的不同时间应用并不构成理由。 –
@ user2407309避免难以解释不规则行为,这在不同的服务器上可能会有所不同,这似乎是一种很好的做法。 – Gerben