Home mod_rewrite redirect complex old url to new one
Reply: 1

mod_rewrite redirect complex old url to new one

R_K
1#
R_K Published in 2018-02-14 08:24:27Z

I have a complex URL that an old website used to use for a specific page. In the new, updated website, this URL became much shorter and much less complex (in fact, the old one doesn't exist no longer). I'm trying to redirect the old URL, when entered in the browser or linked to from an email, to the new, shorter, and actually existing URL.

I've tried countless of things but I'm just really bad at everything mod_rewrite related. Needless to say, I'm trying to do this in my .htaccess file.

Old url: www.domain.com/Event.211.0.html?&tx_calendar_pi1%5Bf1%5D=1061&tx_calendar_pi1%5Bf4%5D=1519102800&cHash=b884377a19d2bc32558d8c3ae232bedf

New url: www.domain.com/events/februarypowerlunch/

Any suggestions, anyone?

Mohammed Elhag
2#
Mohammed Elhag Reply to 2018-02-16 12:22:50Z

Try the following code :

RewriteEngine On 
RewriteCond %{REQUEST_URI}  !^/events/februarypowerlunch/
RewriteCond %{THE_REQUEST} ^(.*)\?(.*)\%(.*)\%(.*)=(.*)\%(.*)\%(.*)$ 
RewriteRule ^     /events/februarypowerlunch/?  [R=302,L]

If it is Ok , change 302 with 301 to get permanent redirection .

Update :

if you want to match only Event.211.0.html do this :

RewriteEngine On 
RewriteCond %{REQUEST_URI}  !^/events/februarypowerlunch/
RewriteRule ^(e|E)vent\.211\.0\.html    /events/februarypowerlunch/?  [R=301,L]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.350126 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO