URL Redirection with .htaccess - .htaccess

Is that possible with .htaccess to redirect like this
example.com/page1-sometext-book to example.com/page1-sometext-booking
example.com/page2-onlytext-book to example.com/page2-onlytext-booking
...
example.com/textN-book to example.com/textN-booking
Thank you.

Related

How do you write a htaccess redirect for pages which look like they're directories?

I'm trying to figure out how to do a 301 redirect for a page who's URL is in the format
www.site.co.uk/foo/bar/
to a URL formatted as
www.site.co.uk/bar.html
I've tried using Redirect which didn't work and I've tried RewriteRule as well but I've not been having much luck.
Could anyone offer some help or link me to some great htaccess tutorials?
Any help would be greatly appreciated.
I've found the solution by reading:
http://perishablepress.com/redirect-subdirectory-to-root-via-htaccess/
The htaccess code is as follows:
RedirectMatch 301 ^/foo/bar/$ http://www.site.co.uk/bar.html

Redirect with HTACCESS without any index files

I have a domain, but it has no files on the webhost. I want to know if it's possible to do the following with only a .htaccess on my webhost.
But what I want to use this basically for is that I want to redirect my web root http://(www.)mydomain.net to http://domain2.net. And I want http://(www.)mydomain.com/1/ redirect to domain3.net.
Can anybody help me out?
Thanks a lot!
Use the htaccess Redirect line..
i think it would be this (i didn't check to verify it works... but fiddle with it):
Redirect http://mydomain.net http://domain2.net
Redirect http://mydomain.net/1 http://domain3.net
http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
You can do this with s simple 301 directive mixed with directories:
I would point mydomain1.com to ip xxx.xxx.xxx.xxx/mydomain1 and then in the htaccess in that directory:
Redirect 301 / http://domain1.net/
Then you can repeat the same for site 2: point site to to ip xxx.xxx.xxx.xxx/mydomain2 and in the htaccess for that directory
Redirect 301 / http://domain2.net/

htaccess rule for url redirect

http://abc.com/forum/forum/topic/topic-1/
to
http://abc.com/forum/topic/topic-1/
please help me to write htaccess rule to get above url .
I want to remove extra 'forum' from the url.
Try this code inside htaccess file:
redirect http://abc.com/forum/forum/topic/topic-1/ http://abc.com/forum/topic/topic-1/

htaccess redirect index.php?v=1 to index.html

I am trying to redirect this page /index.php?route=common/home to index.html
and have put this in my .htaccess page:
Redirect 301 index.php?route=common/home index.html
However, I get a 500 Internal Server Error when I do this.
Does anyone know how to do this correctly?
(Note: there are other pages example /index.php?route=checkout which I don't want to redirect)
Any help would be greatly appreciated.
Thank you
Redirect is just really used to make aliases (and is part of mod_alias). Instead, you need to use mod_rewrite, so RewriteRule /index.php?route=common/home index.html [R=301] should work, but check it first.

.htaccess for cakephp

I am runing a site wishberry.in on cakephp framework. I had some dirty URLs previously and now i want them to cleanup through .htaccess
I original url was wishberry.in/createwishlist3 and i want to change that to wishberry.in/brands with a 301 redirect.
The reason for using 301 is, if someone type wishberry.in/createwishlist3, the page will take them to /brands automatically.
Can anyone help me out what to write in my .htaccess file.
I would recommend doing this with routes in CakePHP rather than the .htaccess file. See http://bakery.cakephp.org/articles/Frank/2009/11/02/cakephp-s-routing-explained for more details.
The following should do the trick:
RewriteEngine On
RewriteRule ^createwishlist3$ /brands [R=301,L,NC]
Hope this helps.

Resources