以下是我目前在.htaccess
文件中写的内容:
RewriteEngine on
RewriteRule ^contact contact.php
RewriteRule ^browse browse.php
RewriteRule ^contact/ contact.php
RewriteRule ^privacy privacy-policy.php
RewriteRule ^signup register.php
RewriteRule ^register register.php
因此,当用户请求http://mydomain.com/welcome时未在.htaccess
文件中定义时,将导致“未找到404”页面。
相反,我想将未在.htaccess
中明确定义的页面重定向到另一个脚本,并传递原始URL。我不想在这里使用ErrorDocument
。我怎么能这样做?
答案 0 :(得分:1)
RewriteEngine on
RewriteRule ^contact contact.php
RewriteRule ^browse browse.php
# why is contact the only one with a slash at the end?
RewriteRule ^contact/ contact.php
RewriteRule ^privacy privacy-policy.php
RewriteRule ^signup register.php
RewriteRule ^register register.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /other.php [L]