i need help setting up 301 redirect something like
the URL domain.com/f446623/welcome-new-guest/ need to be redirected to domain.com/folder/welcome-new-guest.446623/
basically f will become folder and numbers which are post IDs moved at end after the title along with dot.
You can use this rule in your DOCUMENT_ROOT/.htaccess file:
RedirectMatch 301 ^/f([0-9]+)/([^/]+)/?$ /folder/$2.$1
Related
I want to edit .htaccess placing the lines below into a single line:
Redirect 301 "/smartphone" "/roster.php"
Redirect 301 "/mobile" "/roster.php"
How can I do that?
The corresponding RedirectMatch directive allows you to use a regex. For example:
RedirectMatch 301 ^/(smartphone|mobile) /roster.php
Reference:
https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch
i am trying to redirect /article/1 to /article/1/title-of-blog
using this htaccess line
Redirect 301 /article/1 /article/1/title-of-blog
when i do that
my new link will be
https://www.mysite,com/article/1/title-of-blog/title-of-blog/title-of-blog/title-of-blog
as this loop keep going
so how to fix this problem
thanks in advance
Is /article/1 the end of the URL you want to redirect?
If so, use $ to indicate that this is where the URL ends.
ie. RewriteRule /article/1$ https://example.com/article/1/title-of-blog [R=301]
To fix this, the destination should be a full URL. This will look something like:
Redirect 301 /article/1 http://yourdomain/article/1/title-of-blog
For example, if your domain was example.com, you would have:
Redirect 301 /article/1 http://example.com/article/1/title-of-blog
I want to do this in .htaccess:
a URL like
http://example.com/folder/different-name
to be redirected to:
http://example.net/different-name
Where at the first site 'folder' is always the same, but 'different-name' is always different
I found a solution:
RedirectMatch 301 /folder(.*)/ http://example.com/$1
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
I'm using ExpressionEngine and it is generating a URL like this when viewing a specific category:
domain.com/index.php/template_group/template/category_URL_indicator/foo_category/
I would like to redirect visitors if they delete the specific category from the final segment of the URL. For example, if they made the URL this:
domain.com/index.php/template_group/template/category_URL_indicator/
I tried an .htaccess 301 redirect but redirecting the shorter URL also redirected the longer URL. That is, if I put this in .htaccess:
redirect 301 http://www.domain.com/index.php/template_group/template/category_URL_indicator http://www.domain.com
This also redirected the longer URL to become http://www.domain.com/foo_category/ - not what was required... Any suggestions welcome - thanks!
David.
Try using redirect match instead, along with begin/end boundaries:
redirect 301 ^index.php/template_group/template/category_URL_indicator$ http://www.domain.com