Как переписать URL с помощью .htaccess, который содержит несколько переменных GET

1

Я использовал.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

Я полностью зациклен на том, как переписать этот url из-за переменных GET. Я был бы рад просто заменить 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"
Теги:
.htaccess
mod-rewrite
url-rewriting

1 ответ

0
Лучший ответ

Я понял это для себя, используя следующий код;

RewriteRule ^property-search/?$ property_search.php [NC,L,QSA]

QSA является основной частью, поскольку она добавляет строку запроса из запроса к замещенному URL-адресу

Ещё вопросы

Сообщество Overcoder
Наверх
Меню