Question

I need to have URL's from an old structure redirect to a new structure.

Old URL:

http://domain.com/index.php?name=PNphpBB2&file=viewtopic&p=28341&highlight=inner#28341

New URL:

http://domain.com/viewtopic.php?p=28341&highlight=inner#28341

How can I do this via htaccess? Or do I need to add something to /index.php file?

Thanks in advance.

Was it helpful?

Solution

You can use this rule in root .htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+index\.php\?name=[^&]*&file=viewtopic&p=([^&]+)&highlight=([^&]+) [NC]
RewriteRule ^ /viewtopic.php?p=%1&highlight=%2#%1 [R=302,L,NE]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top