htaccess 301 subdomain moved - .htaccess

I want to redirect URLs like http://www.site.gen.tr/index.php?ind=reviews&op=entry_view&iden=2381 to http://arsiv.site.gen.tr?ind=reviews&op=entry_view&iden=2381 site.
I tried using .htaccess but could not make it work. Please help.

You should put this in your .htaccess file (need to be in domain root)
RewriteEngine On
Redirect 301 http://www.site.gen.tr/index.php?ind=reviews&op=entry_view&iden=2381 http://arsiv.site.gen.tr?ind=reviews&op=entry_view&iden=2381

Related

.htacess redirect directory to one domain and subdirectory to different domain

Having trouble creating/finding the correct Rewrite rules for this...
domain1.com/abc -> domain2.com/crazylongurl
domain1.com/abc/def -> domain3.com/differentcrazylongurl
I currently have
RewriteEngine on
Redirect 301 /abc domain2.com/crazylongurl
And that works. But I can't get the /def subdirectory to go to a different url. Is that possible?
I figured it out! I didn't know about negative lookaheads. So, in the domain.com/abc directory, I put an .htaccess file with this in it:
RewriteEngine On
RedirectMatch 301 /abc(?!/def) domain2.com/crazylongurl
And in the domain.com/abc/def directory, I put an .htaccess file with this in it:
ReWriteEngine On
Redirect /abd/def domain3.com/differentcrazylongurl

htaccess redirect 301 and rewrite

I am trying to simplify URLs from
xyz.com/walks/walk_descrip/8010/
to
xyz.com/walk-8010
I have moved the file from the walks sub-directory to the root.
I have tried using the following in my htaccess file
Redirect 301 ^/walks/walk_descrip/(.*)/$ /walk-$1
RewriteRule ^walk-(.*)$ /walk-description.php?id=$
However this is producing URLs such as
xyz.com/walk-8010?id=8010
Where am I going wrong?
Any help would be appreciated
Redirect directive doesnt support regex. What you are looking for is RedirectMatch.
RedirectMatch 301 ^/walks/walk_descrip/(.+)$ /walk-$1

Friendly URL or url-rewriting

I am working on a site that uses such a url
www.domain.com/hotels/hotel-name
I would like visitors just to see
www.domain.com/hotel-name
This can probably be done in the .htaccess file with a rewrite condition but I don't know how.
Thank you for helping
You can use RedirectMatch directive :
Put the following Redirect above other rules in your htaccess file
RedirectMatch 301 ^/hotels/([^/]+)/?$ /$1
This example would redirect all files from the /hotels/ folder, if you want to redirect a particular file from that folder , you can use the following:
RedirectMatch 301 ^/hotels/(file_name)/?$ /$1
Now if a visiter enters www.example.com/hotels/hotel-name then will be externally redirected to www.example.com/hotel-name

Redirect URL to a IP address

I need to redirect a url www.website.com/page to a Ip address 192.000.00.000:1234
Do i have to do this through the Cpanel or is there a way to do it in the .htaccess
Cant find anything that describes how to do it.
Thanks
Had to use
Redirect 301 /page.php http://192.000.00.000:1234
For it to work. Was on a wordpress site.
Have you tried:
Redirect 301 / 192.000.00.000:1234
?
Enable .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
RedirectMatch 301 ^/page\.php$ http://192.000.00.000:1234

How to do 301 redirects with folders & subfolders?

I need to redirect all the old URLs on my site to new URLs, but am having issues. A given URL and its subfolders need redirecting to the same page.
For example, this is the first one:
redirect 301 /panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html
This works ok. However there are these size sub-pages which need to redirect to the same location:
redirect 301 /panache/sports-bra/30DD http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30E http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30F http://www.newdomain.co.uk/sports-bra.html
And these don't work, I end up at a location like the following:
http://www.newdomain.co.uk/sports-bra.html30DD
See the way the last part of the path is appended to the url? I'm guessing it's because the second redirect is conflicting with the initial 301 redirect?
I have also tried using this rewrite rule but have had no luck. The site is Magento so I don't know if this has some effect? mod_rewrite is enabled on the server.
RewriteRule ^panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html [R=301]
Any help mucha ppreciated.
Try this.
RewriteEngine on
RewriteRule ^(panache/sports-bra/.*)$ /sports-bra.html [L,R=301,NC]

Resources