how i can solve this?
.htaccess
Redirect 301 /item/ /itemlist/
yes it works but not perfect!
Check this:
domain.com/item/ = domain.com/itemlist/ = OK
domain.com/item/archive/ = domain.com/itemlist/archive/ = OK
domain.com/item/single-item/ = domain.com/itemlist/single-item/ = FAIL
last item should be:
domain.com/item/single-item/
So how i can say only if "/item/" is detect in URL without any other stuff after this?
Redirect will match the front of a URL.
Use RedirectMatch for more precision. It accepts regular expressions.
RedirectMatch 301 "^/item/$" /itemlist/
… remember that your browser is likely to have cached your previous 301 redirects so it might not appear to be working when you remove the old Redirect directives you have.
Related
I need to redirect a url like this:
https://zzz.com/Class/Today-Class-100
to
https://zzz.com/otherfolder/
BUT leave a url like this
https://zzz.com/de/Class/Today-Class-100
alone. Right after the .com we have language directories, and those should not redirect. Only the first one should - how do I redirect an EXACT URL and leave ones with any difference alone?
This did not work:
RedirectMatch 301 ^/Class/Today-Class-101$ https://zzz.com/otherfolder/
as it still redirected with a subfolder in front of
/Class/Today-Class-101$
Running into this issue where the redirect in the second line is redirecting to the URL in the first line.
Redirect 301 /academics/degrees http://mydomain.edu/folder1/location1/
Redirect 301 /academics/degrees/phd http://mydomain.edu/folder1/location2/
At first I thought it had something to do with the locations to be redirected containing hyphens, but haven't been able to find anything on that.
Does it have something to do with the locations to be redirected sharing the same folder/permalink structure?
I've never encountered this before and am totally lost. I tried RedirectMatch but that didn't have any effect.
It is because /academics/degrees matches both URLs and rule for /academics/degrees/phd never fires. Either change the order of your rule OR better use RedirectMatch with regex capability to match only desired URL pattern:
RedirectMatch 301 ^/academics/degrees/?$ http://mydomain.edu/folder1/location1/
RedirectMatch 301 ^/academics/degrees/phd/?$ http://mydomain.edu/folder1/location2/
Make sure to clear your browser cache before testing this change.
I have this weird URL, /andy-sixx-2012-short-hair%3Eandy. I've tried this:
Redirect 301 /andy-sixx-2012-short-hair%3Eandy http://mysite.com/page.html
but that fails. I can redirect something like /andy-sixx-2012-short-hairandy no problem so the issue seems to be the %3E character. Any help would be great. Thanks!
The URI is decodeded before modules like mod_alias or mod_rewrite gets to process them, thus you need to match against > and not %3E:
Redirect 301 /andy-sixx-2012-short-hair>andy http://mysite.com/page.html
I got some problem on redirecting something.
I tried to use Redirect 301 /link/link/link to /link/link
Is there a way to make it more easier coz there are 100+ links I need to redirect.
Like this
/blog/category/energy-savings/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing
/blog/category/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/
/blog/category/uncategorized/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/about
/blog/category/uncategorized/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/about
/blog/category/uncategorized/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing
/blog/category/uncategorized/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/about
/blog/category/water-conservation/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing
/blog/category/water-conservation/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/plumbing/about
To the Homepage?
Thanks
The directive:
Redirect 301 /link/link/link /link/link
Doesn't do what you think it does. It's mapping to nodes together, meaning a request for:
/link/link/link/foo/bar.html
gets redirected to:
/link/link/foo/bar.html
So maybe you need to fix that. You could try:
RedirectMatch 301 ^/link/link/link/?$ /link/link
so the nodes aren't connected like in the Redirect directive. As for trying to "fix" this problem of yours, you can try:
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/\4/ /
This redirects anything that looks like: /blah1/blah2/blah3/same/same/same/ etc. to the homepage at /. The \4 matches the 4th path in the URI, so if anything after the 3rd path repeats, then it redirects.
i want to redirect a page:
http://www.mysite.com/samplepage/
Pages like http://www.mysite.com/samplepage/samplepage2/ shall not be redirected.
This is my current .htaccess code:
RedirectMatch 301 ^/samplepage/ /new-samplepageurl
The problem:
This one also redirects url's like:
http://www.mysite.com/samplepage/samplepage2/
Can I limit the redirect only to that one exact path?
Try using this:
RedirectMatch 301 ^/samplepage/?$ /new-samplepageurl
The $ sign marks the end of string, and ? mark makes the trailing slash opional (e.g. both /samplepage and /samplepage/ will be redirected)