[英].htaccess dynamic URL redirect
Unable to redirect dynamic URL after rewriting it. 重写后无法重定向动态URL。
Dynamic URL: http://localhost/amploutargetsharing/campaigninfo.php?unique_hash=f5f386e 动态网址: http://localhost/amploutargetsharing/campaigninfo.php?unique_hash = f5f386e
after Redirection I want the URL to look like below. 重定向后,我希望URL看起来如下所示。
Desired URL: http://localhost/amploutargetsharing/f5f386e 所需的URL: http:// localhost / amploutargetsharing / f5f386e
As I google this and write below code. 当我谷歌这个并写下面的代码。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/amploutargetsharing/campaigninfo\.php$
RewriteCond %{QUERY_STRING} ^unique_hash=([a-z0-9]*)$
RewriteRule ^(.*)$ http://localhost/amploutargetsharing/%1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ campaigninfo.php?unique_hash=$1 [L,QSA]
And above code is giving me the below result. 以上代码给出了以下结果。
http//localhost/amploutargetsharing/f5f386e?unique_hash=f5f386e HTTP本地主机// / amploutargetsharing / f5f386e?unique_hash = f5f386e
But I want the URL to look like the above desired URL. 但我希望URL看起来像上面所需的URL。
Try this : 尝试这个 :
RewriteEngine On
RewriteCond %{THE_REQUEST} /amploutargetsharing/campaigninfo.php\?unique_hash=([^&\s]+) [NC]
RewriteRule ^ amploutargetsharing/%1? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ amploutargetsharing/campaigninfo.php?unique_hash=$2 [QSA,L,NC]
Try these rules in /amploutargetsharing/.htaccess
: 在/amploutargetsharing/.htaccess
尝试以下规则:
RewriteEngine On
RewriteBase /amploutargetsharing/
RewriteCond %{THE_REQUEST} /campaigninfo.php\?unique_hash=([^&\s]+) [NC]
RewriteRule ^ %1? [L,NE,R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ campaigninfo.php?unique_hash=$1 [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.