使用htaccess和mod_rewrite更改URL

时间:2014-08-13 09:13:07

标签: php apache .htaccess mod-rewrite

我的网址是http://www.testsite.com/cities?city=hyderabad

我想将其更改为http://www.testsite.com/hyderabad

我的htaccess中的代码是

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteRule ^\.htaccess$ - [F]
    RewriteCond %{REQUEST_URI} =""
    RewriteRule ^.*$ /public/index.php [NC,L]
    RewriteCond %{REQUEST_URI} !^/public/.*$
    RewriteRule ^(.*)$ /public/$1
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^/public/.*$ /public/index.php [NC,L]

0 个答案:

没有答案