.htaccess 动态 URL 重定向
.htaccess dynamic URL redirect
重写后无法重定向动态URL。
动态URL:http://localhost/amploutargetsharing/campaigninfo.php?unique_hash=f5f386e
重定向后,我希望 URL 如下所示。
期望URL:http://localhost/amploutargetsharing/f5f386e
因为我google这个并写了下面的代码。
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= [L,QSA]
上面的代码给出了下面的结果。
http//localhost/amploutargetsharing/f5f386e?unique_hash=f5f386e
但我希望 URL 看起来像上面想要的 URL。
试试这个:
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= [QSA,L,NC]
在 /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= [QSA,L]
重写后无法重定向动态URL。
动态URL:http://localhost/amploutargetsharing/campaigninfo.php?unique_hash=f5f386e
重定向后,我希望 URL 如下所示。
期望URL:http://localhost/amploutargetsharing/f5f386e
因为我google这个并写了下面的代码。
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= [L,QSA]
上面的代码给出了下面的结果。
http//localhost/amploutargetsharing/f5f386e?unique_hash=f5f386e
但我希望 URL 看起来像上面想要的 URL。
试试这个:
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= [QSA,L,NC]
在 /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= [QSA,L]