【问题标题】:Change the url using .htaccess使用 .htaccess 更改网址
【发布时间】:2013-01-20 16:37:46
【问题描述】:

我只想使用 htaccess 更改我网站的 url。请告诉我是否可以改变 网址 “www.mysite.com/carbooking”到“www.mysite.com/cars”。 “www.mysite.com/avaibletickets”到“www.mysite.com/tickets”等等。

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    使用来自Apache 的Redirect 指令。例如:

    Redirect /carbooking http://www.mysite.com/cars
    

    或重写规则:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^carbooking$ http://anvi.hostoi/cars [L]
    

    【讨论】:

    • 我以前没试过这个。所以请给我完整的代码。现在在我的 .htaccess 文件中插入什么?
    • 只需将这一行放到您的 .htaccess 文件中,看看它是否有效。每个重定向需要一行。
    • 我的代码是: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php Redirect /flighttickets mysite.com/flights Redirect / holiday-india mysite.com/india Redirect /holidays-world mysite.com/world Redirect /carbooking mysite.com/cars Redirect /busbooking mysite.com/buses Redirect /hotelbooking mysite.com/hotels Redirect /miceenquiry mysite.com/mice Redirect /contactuspage mysite.com/support
    • 您将重定向与重写规则混合在一起。在这种情况下,最好只切换到重写规则。对于汽车,在RewriteEngine on 之后使用这个:RewriteRule ^/carbooking$ http://anvi.hostoi/cars [L]
    • RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^/flighttickets$ mysite.com/flights[L] RewriteRule ^/holidays -india$ mysite.com/india[L] RewriteRule ^/holidays-world$ mysite.com/world[L] RewriteRule ^/carbooking$ mysite.com/cars [L] RewriteRule ^/busbooking$ mysite.com/buses[L] RewriteRule ^/hotelbooking$ mysite.com/hotels[L] RewriteRule ^/33655$ @9876 @RewriteRule ^/contactuspage$ mysite.com/support[L]
    猜你喜欢
    • 1970-01-01
    • 2012-09-15
    • 2014-06-12
    • 2016-07-17
    • 1970-01-01
    • 2019-02-09
    相关资源
    最近更新 更多