htaccess文件中的url重写转到404 Page Not Found

时间:2014-12-19 17:21:04

标签: .htaccess mod-rewrite url-rewriting

以下是我的完整.htaccess文件。它在本地主机上工作正常。但它在共享主机中找不到404页面。任何人都可以帮我解决这个问题

RewriteEngine On 

    RewriteBase /


    RewriteCond %{THE_REQUEST} /index\.php\?search_location=([^\s&]+)&search_for=([^\s&]+)&search_type=([^\s&]+)&page=([^\s&]+) [NC]
    RewriteRule ^ %1/%2/%3/%4? [R=302,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([A-Za-z0-9-+]+)/([A-Za-z0-9-+]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$index.php?search_location=$1&search_for=$2&search_type=$3&page=$4 [L,QSA]

1 个答案:

答案 0 :(得分:0)

这不可能是那样的一行:

RewriteRule ^([A-Za-z0-9-+]+)/([A-Za-z0-9-+]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$index.php?search_location=$1&search_for=$2&search_type=$3&page=$4 [L,QSA]

使用:

RewriteRule ^([A-Za-z0-9-+]+)/([A-Za-z0-9-+]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?search_location=$1&search_for=$2&search_type=$3&page=$4 [L,QSA]

?$

之后有一个空格