htaccess - 重写网址根本不起作用

时间:2016-07-15 11:23:47

标签: php apache .htaccess url-rewriting

我在CentOS 6上使用Apache,在我的htaccess中我有这行代码将url重写为更友好的读者

RewriteRule ^destinations/(.*)$ destinations.php?destId=$1 [R=301,L,NE]

它应该rewrite example.com/destinations/floridaexample.com/destinations.php?destId=florida

在我的页面目标.php我没有从

获得任何输出
echo $_GET['destId'];

我可以发誓几天前它正常工作,但现在不行了。首先,我添加了R=301来查看浏览器中的网址更改,但ID并不是。我已经检查了一百次,但这里没有语法错误。这是另一个没有工作的人

RewriteRule ^tours/?(.*)$ tour-listing.php?cat=$1 [NC,L]

虽然这个确实有用

RewriteRule ^bnb-in-(.*)$ hotel-search.php?t=bnb&s=$1 [NC,L]

他们全部在一个文件中。所有这些都在localhost上工作。我最近修改了apache的httpd.conf文件以安装SSL证书,所以我的猜测是出了问题。这是代码:

<VirtualHost ser.ver.ip.addr:80>
    ServerName www.example.in
        ServerAlias example.in
    Redirect "/" "https://example.in/"
</VirtualHost>
<VirtualHost ser.ver.ip.addr:443>
        ServerName example.in:443
        ServerAlias www.example.in
        DocumentRoot /home/veek/public_html
       SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/certfile.crt
        SSLCertificateKeyFile /etc/ssl/private/keyfile.key
        SSLCertificateChainFile /etc/ssl/certs/intermediate.pem
        SSLProtocol all -SSLv2 -SSLv3
        SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES2$
        SSLHonorCipherOrder on

        <Directory /home/veek/public_html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ServerAdmin webmaster@example.in
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/example.in combined
    CustomLog /usr/local/apache/domlogs/example.in-bytes_log "%{%s}t %I .\n%{%s}t %O ."
         UserDir enabled veek
    <IfModule mod_suphp.c>
        suPHP_UserGroup veek veek
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup veek veek
        </IfModule>
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid veek veek
    </IfModule>
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID veek veek
    </IfModule>

    ScriptAlias /cgi-bin/ /home/veek/public_html/cgi-bin/

</VirtualHost>

这是完整的htaccess文件

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s/+(.+?)/+[?\s]
RewriteRule /$ /%1 [R=301,L,NE]

RewriteRule ^destinations/(.*)$ destinations.php?destId=$1 [L,NC]

RewriteRule ^tours/(.*)$ tour-listing.php?cat=$1 [NC,L]
RewriteRule ^tour/(.*)$ tour.php?tourId=$1 [NC,L]

RewriteRule ^hotels-in-(.*)$ hotel-search.php?s=$1 [NC,L]
RewriteRule ^hotels hotel-search.php [NC,L]
RewriteRule ^hotel/(.*)$ hotel-details.php?id=$1 [NC,L]

RewriteRule ^bnb-in-(.*)$ hotel-search.php?t=bnb&s=$1 [NC,L]
RewriteRule ^bnb hotel-search.php?t=bnb [NC,L]

RewriteRule ^camps-in-(.*)$ hotel-search.php?t=camps&s=$1 [NC,L]
RewriteRule ^camps hotel-search.php?t=camps [NC,L]

RewriteRule ^thank-you message.php?id=1 [NC,L]

RewriteRule ^404 message.php?id=2 [NC,L]
ErrorDocument 404 /404

有什么想法吗?

0 个答案:

没有答案