我使用以下代码重写了我的这个网址:
用'/'替换查询字符串,所以它是http://example.com/foldername/sa/new+york/hotel/north+park?
我使用以下htaccess代码实现了这一点。
RewriteCond %{THE_REQUEST} \ /+foldername/New-York-Mills\.php\?ff_nm_from=([^&]+)&search=([^&\ ]+)&location=([^&\ ]+)
RewriteRule ^ /foldername/sa/%1/%2/%3? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^foldername/sa/([^/]+)/([^/]+)/([^/]+)$ /Just-dial/New-York-Mills.php?ff_nm_from=$1&search=$2&location=$3 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /style.css [NC]
RedirectMatch 301 ^/(.*)\%2[Cc](.*)$ /$1$2?
RewriteRule ^foldername/sa/(.+)/(.+)/(.+)/(.+)/? foldername/sa/$1.php?ff_nm_from=$2&search=$3&location=$4
但我希望我的网址像以下网址一样。这意味着我想在查询字符串后从url中删除第一个变量。 http://example.com/foldername/New-York-Mills/hotel/north+park
如何使用.htaccess文件完成?
答案 0 :(得分:0)
如果我理解正确,您可以替换您的第一组重写条件并对此进行规则:
RewriteCond %{THE_REQUEST} ^/foldername/New-York-Mills\.php
RewriteCond %{QUERY_STRING} ff_nm_from=([^&]+)&search=([^&\ ]+)&location=([^&\ ]+)
RewriteRule ^ /foldername/New-York-Mills/%2/%3? [L,R=301]