I'm trying to redirect http://vacation.website.com/category/spa-vacations/ to http://website.com/vacations/spa-vacations/
RewriteEngine On
RewriteRule ^category/(.*)$ $1
RewriteCond %{HTTP_HOST} ^vacation\.website\.com [NC]
RewriteRule ^(.*) https://website.com/vacations/$1 [L,R=301]
With this htaccess, the first rule seems to be applied and removes "category" from the URL - then it's like it never happened and I'm left with http://website.com/vacations/category/spa-vacations/
Why doesn't the first change to the URL stick and is it possible to make it do so?
To redirect
http://vacation.website.com/category/spa-vacations/
to
http://website.com/vacations/spa-vacations/
Try this :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?vacation\.website\.com [NC]
RewriteRule ^category/(.*)$ https://website.com/vacations/$1 [L,R=301]
Note: clear browser cache then test.
Related
I need to make a 301 redirect from
https://www.example.net/sub1/specific_keyword/page1/page2
https://www.example.net/sub2/sub3/specific_keyword/page3/page4
https://www.example.net/specific_keyword/page5/page6
to
https://www.example.net/sub1/
https://www.example.net/sub2/sub3/
https://www.example.net/
I tried this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.net$ [NC]
RewriteRule ^(.*)\/specific_keyword$ "https\:\/\/www\.example\.net\/$1" [R=301,L]
But no luck.
With your RewriteRule attempt, you demanded that the requested URL
ends with /folder-to-remove, via the $ at the end, so that won’t match (Source: #comment120998408_68464303)
With that fixed, place following rules at top of your htaccess Rules file. Make sure to clear your browser cache before testing your URLs or use a redirect checker online.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^www\.example\.net$ [NC]
RewriteRule ^([^/]*)/([^/]*)/.*$ $1/$2? [R=301,NE,L]
OR only match the specific keyword
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)specific_keyword/ https://www.example.com/$1 [R=301,L,NE]
Trying to get
www.example.com
to go directly to
www.example.com/forum
How can I do this with this configuration? Thanks in advance.
Edit:
Right now I have added below content in .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteRule ^(.*)$ /forum/$1 [L,R=301]
I want result like
https://www.example.com/topic/topic-url/
to
https://www.example.com/forum/topic/topic-url/
With your shown samples, could you please try following. Please clear your browser cache before testing your URLs. Your tried rules will be creating an infinite loop hence it may not be working, I have added a condition if uri doesn't start from forum then only proceed with redirection.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteRule ^(.*)$ /forum/$1 [L,R=301]
I want to redirect only /?page=3 to /.
/?page=33 is not redirect.
The following code also redirects /?page=33
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=3$
RewriteRule / [R=301,L]
You can use:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=3$
RewriteRule ^ /? [R=301,L]
With ? to prevent the automatic addition of ?page=3
Try it like this, clear your browser cache first after that if it works change R=302 to 301
RewriteEngine on
RewriteCond %{QUERY_STRING} ^page=3
RewriteRule ^ / [R=302,L]
I have .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^somedomain.com [NC]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [R=301,NC]
RewriteRule ^r/(.*)$ index.php?rid=$1 [NC]
But last condition performs redirect in browser when I request URL like www.somedomain.com/r/123 and show me URL like www.somedomain.com/index.php?rid=123. But I need call this script without URL change.
What's wrong?
You used the R=301 Try to use L just like following:
RewriteCond %{HTTP_HOST} ^somedomain.com [L]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [L]
RewriteRule ^r/(.*)$ index.php?rid=$1 [L]
ive this rules at htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
issue happend when redirect warcraft its redirect to
http://www.site.com/home/site/public_html/www.site.com/forumdisplay.php?f=480
any tip ?
I suppose you want to redirect it to http://www.site.com/forumdisplay.php?f=480
If so put it in your .htaccess file:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ http://www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
You must provide the full URL including protocol in your rule, in this case http://www.site.com/.....