.htaccess dynamic url redirect

Unable to redirect dynamic URL after rewriting it.

Dynamic URL: http: //localhost/amploutargetsharing/campaigninfo.php? Unique_hash = f5f386e

after redirect I want the url to look like below.

Desired URL: http: // localhost / amploutargetsharing / f5f386e

How i google it 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 the above code gives me the following result.

Http // localhost / amploutargetsharing / f5f386e? Unique_hash = f5f386e

But I want the url to look like the above url.

+3


source to share


2 answers


Try these rules in /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]

      

0


source


Try the following:



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]

      

+1


source







All Articles