我想将一个ceraitin请求指向一个特定页面,然后将一个捕获所有其他请求。同时还应用将URL添加到URL的开头的规则。我尝试了多种解决方案,但都无济于事。
这是我最近的尝试。浏览器显示500错误配置消息。
# Add www to domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
# target without trailing slash
RewriteRule ^myWord$ /myWordFolder/index.php [L]
# target with trailing slash
RewriteRule ^myWord/$ /myWordFolder/index.php [L]
# catch all non myWord requests
RewriteRule ^(.*)$ /catchAllFolder/ [L]
答案 0 :(得分:0)
我认为最后一条规则需要有额外条件才能停止重写/catchAllFolder/
次请求。
RewriteEngine On
# Add www to domain
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
# target with/without trailing slash
RewriteRule ^myWord/?$ /myWordFolder/index.php [L]
# catch all non myWord requests
RewriteRule !^catchAllFolder/ /catchAllFolder/ [NC,L]