Knowledgebase

apache rewrite rule help

Posted by vpswing, 01-07-2013, 09:22 PM
Hi, Does anyone know to rewrite the following url: http://somesite.com/wip/page1/ --> http://somesite.com/page1/ http://somesite.com/wip/page2/ --> http://somesite.com/page2/ http://somesite.com/wip/page3/ --> http://somesite.com/page3 Basically removing the folder 'wip' from the url? Many thanks! Cheers, XW

Posted by dareORdie, 01-07-2013, 09:27 PM
If you want to redirect only some of the pages to be redirected to other page using 301 redirection then you can check below methods to write code in .htaccess. #Method 1 Redirect 301 /oldpage.html http://newsite.com/newpage.html #Method 2 RewriteRule ^oldpage.html$ http://newsite.com/newpage.html [R=301] Redirect Whole Site Using 301 If you are moving to new website and want all your visitor of old site being redirected to new site then here is the code for you. #Method 1 Redirect 301 / http://newsite.com/ #Method 2 RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]

Posted by vpswing, 01-07-2013, 09:33 PM
Thanks for the tips mate, but I want to remove the "wip" (work in progress) folder from the URL. Everything else remains the same. Idea idea how? Many thanks! Cheers, XW

Posted by ACTCS, 01-15-2013, 09:02 PM
There are a couple easy ways to do this, it depends on your environment and reasoning. Is there a reason you don't just move the files? On a *nix server you could also symlink the directories. I try to avoid a rewrite unless there's a serious reason for it.

Posted by nettiapina, 01-16-2013, 12:41 AM
Dareordie provided you the answer. Just take his RewriteRule (method #2) and remove [R=301]. If you can't get that to work (by doing the obvious little changes), your CMS or server might be interfering with the rewrite. I would just copy the files or change the website root directory. Much cleaner and simpler.

Posted by kevincheri, 01-16-2013, 12:52 AM
use this RedirectMatch 301 /wip/page1/(.*) /page1/$1

Posted by vpswing, 01-16-2013, 04:05 AM
Thanks for all your answers guys! This works like a charm: RedirectMatch 301 /wip/(.*) /$1 Cheers!

Posted by kevincheri, 01-16-2013, 03:06 PM
Great to hear that mate



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
thenynoc down (Views: 606)
Cpanel Consultants? (Views: 645)


Language:

Client Login

Email

Password

Remember Me

Search