.htaccess 问题:缩短动态URL

.htaccess 问题:缩短动态URL,.htaccess,mod-rewrite,asp-classic,helicontech,.htaccess,Mod Rewrite,Asp Classic,Helicontech,我已经搜索并尝试了几种可能的解决方案 我首先说: http:// example.com/ 729/start-page.asp?cid=4004 http:// example.com/ 729/start-page.asp?cid=7916 http://example.com/729/start page.asp?cid=4004 http://example.com/729/start page.asp?cid=7916 并尝试: http:// example.com/ johns

我已经搜索并尝试了几种可能的解决方案

我首先说:

http:// example.com/ 729/start-page.asp?cid=4004 http:// example.com/ 729/start-page.asp?cid=7916 http://example.com/729/start page.asp?cid=4004 http://example.com/729/start page.asp?cid=7916 并尝试:

http:// example.com/ johns-start-page http:// example.com/ judys-start-page http://example.com/johns起始页 http://example.com/judys起始页 或如有可能:

http:// johns-start-page.example.com/ http:// judys-start-page.example.com/ http://johns-start-page.example.com/ http://judys-start-page.example.com/ 到目前为止,我已经:

RewriteEngine on RewriteCond %{QUERY_STRING} ^cID=4004$ RewriteRule ^729\.asp$ /johns-start-page [NC,R=301,L] RewriteCond %{QUERY_STRING} ^cID=7916$ RewriteRule ^729\.asp$ /judys-start-page [NC,R=301,L] 重新启动发动机 RewriteCond%{QUERY_STRING}^cID=4004$ 重写规则^729\.asp$/johns起始页[NC,R=301,L] RewriteCond%{QUERY_STRING}^cID=7916$ 重写规则^729\.asp$/Judy起始页[NC,R=301,L]
只要您正在硬编码这些内容,您就可以尝试:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=4004($|\ |\&)
RewriteRule ^ /johns-start-page? [L,R=301]

RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=7916($|\ |\&)
RewriteRule ^ /judys-start-page? [L,R=301]

RewriteRule ^johns-start-page$ /729/start-page.asp?cid=4004 [L,QSA]
RewriteRule ^judys-start-page$ /729/start-page.asp?cid=7916 [L,QSA]
对于子域,您需要确保您有DNS设置,以将这些子域指向相同的IP地址。然后是:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^johns-start-page\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=4004($|\ |\&)
RewriteRule ^ http://johns-start-page.example.com/? [L,R=301]

RewriteCond %{HTTP_HOST} !^judys-start-page\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=7916($|\ |\&)
RewriteRule ^ http://judys-start-page.example.com/? [L,R=301]

RewriteCond %{HTTP_HOST} ^johns-start-page\.example\.com$ [NC]
RewriteRule ^$ /729/start-page.asp?cid=4004 [L,QSA]

RewriteCond %{HTTP_HOST} ^judys-start-page\.example\.com$ [NC]
RewriteRule ^$ /729/start-page.asp?cid=7916 [L,QSA]

但是,除非您将链接设置为包含FQDN,否则您的所有链接都可能会断开。

@Jon Lin尝试了您的第一个解决方案,但被忽略。我不确定{THE_REQUEST}是占位符还是RewriteCond%{THE_REQUEST}逐字进入代码。这是我的第一个问题。我现在明白了,这是一个被问得很糟糕的问题,或者是一个只有-2票的糟糕问题。我本可以在更好的问题上使用建议,而不是踢屁股。非常感谢。