[英]How to rewrite a URL using .htaccess that contains multiple GET variables
我已经使用.htaccess重写了我网站上除此页面以外的所有页面的URL;
https://www.atlasestateagents.co.uk/property_search.php?sort=3&availability=1&location=Liverpool&radius=50&min_price=&max_price=&min_beds=&max_beds=&type=&added=&available=1
由于GET变量的缘故,我完全沉迷于如何重新编写此URL。 我很乐意将property_search.php
替换为property_search
并保留其余URL。
我的.htaccess文件;
RewriteEngine On # Turn on the rewriting engine
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.atlasestateagents.co.uk/$1 [R=301]
RewriteCond %{HTTP_HOST} !^www.atlasestateagents.co.uk$ [NC]
RewriteRule ^(.*)$ https://www.atlasestateagents.co.uk/$1 [R=301]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
RewriteRule ^about/?$ about.php [NC,L]
RewriteRule ^contact/?$ contact.php [NC,L]
RewriteRule ^landlords/landlord-services-and-fees/?$ landlords/landlord-services-and-fees.php [NC,L]
RewriteRule ^vendors/vendors-services-and-fees/?$ vendors/vendors-services-and-fees.php [NC,L]
RewriteRule ^property-([0-9]+)/(.*)?$ view_property.php?property_id=$1 [NC,L]
Options -Indexes
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresDefault "access plus 2 days"
我使用以下代码自己弄清楚了;
RewriteRule ^property-search/?$ property_search.php [NC,L,QSA]
QSA
是主要部分,因为它会将请求中的查询字符串附加到替换的URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.