0
如果url以雙短劃線或連字符( - )結尾,我需要重定向到某個內部頁面。如果url以雙短劃線結尾,想重寫(Apache)
RewriteEngine On
RewriteCond %{REQUEST_URI} --$
RewriteRule .* /error
www.mySite.com/myPage--將www.mySite.com/error
但它不工作。這段代碼有什麼問題嗎?
我認爲這是因爲它處理特殊字符而不是字符串。
*編輯。
這是我的整個vhost.conf
。
ServerName mysite.com
DocumentRoot "/myWebRoot/"
ErrorDocument 400 /jsp/errorHandler.jsp
ErrorDocument 403 /jsp/errorHandler.jsp
ErrorDocument 404 /jsp/errorHandler.jsp
ErrorDocument 500 /jsp/errorHandler.jsp
ErrorDocument 503 /jsp/errorHandler.jsp
RedirectMatch --$ /jsp/errorHandler.jsp
<IfModule mod_jk.c>
JkMount /*.jsp mysite
JkMount /*.do mysite
JkMount /*.page mysite
JkMount /*.json mysite
JkMount /servlet/* mysite
</IfModule>
<LocationMatch "/servlet/*">
SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME mysite
</LocationMatch>
<LocationMatch "/*\.(do$|jsp$)">
SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME mysite
</LocationMatch>
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresByType image/x-icon "access plus 2592000 seconds"
......
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<LocationMatch "\.(json)$">
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
</LocationMatch>
<LocationMatch "\.(do)$">
Header set Cache-Control "max-age=8640000, public, must-revalidate"
</LocationMatch>
<LocationMatch "/*/header.jsp">
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
</LocationMatch>
</ifModule>
# END Cache-Control Headers
<Directory "/myWebRoot/">
Options -Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
Allow from all
Deny from env=go_out
</Directory>
我想你的,但沒有工作..真的很怪 – Deckard
「不工作」什麼都沒告訴我。這是在.htaccess文件中還是在虛擬主機配置中?你有其他可能會干擾的RewriteRules嗎? – mrjink
這是我的虛擬主機配置。(vhost.conf)我將把我的整個配置代碼添加到問題中。在我看來,沒有什麼會干擾RewriteRules。 – Deckard