Hi looking for some help, i have a product link
iphone%20-5c-replacement-button
i have removed the blank space and i am trying to set up a "301 rewriterule" to the new page.
i tried this
RewriteRule ^iphone%20-5c-replacement-button$ /iphone-5c-replacement-button [R=301,L]
But this did not work, so i tried this way
Redirect 301 "/iphone -5c-replacement-button" http://www.mysite.co.uk/iphone-5c-replacement-button
i also tried
Redirect 301 "/iphone -5c-replacement-button" "http://www.mysite.co.uk/iphone-5c-replacement-button"
can anyone please help with this problem
You can match the space %20 using \s char in RewriteRule
RewriteRule ^iphone\s-5c-replacement-button$ /iphone-5c-replacement-button [R=301,L]
Related
I would like to make a redirect using htaccess rules to point ALL links from
mywebsite.com/subfolder1/subfolder2/...whatever-path....
to
mywebsite.com/subfolder1
But the problem is that whatever rule I use it always keeps the old path in the destination link, for example:
mywebsite.com/subfolder1/subfolder2/mypage.php
becomes
mywebsite.com/subfolder1/mypage.php
I tried all the following possibilities:
RewriteRule (.*) https://mywebsite.com/subfolder1/$1 [R=301,L]
RewriteRule ^subfolder1/subfolder2/(.*)$ /subfolder1/$1 [R=301,NC,L]
RewriteRule ^/subfolder1/subfolder2/(.*)$ /subfolder1/$1 [R=301,NC,L]
Redirect 301 /subfolder1/subfolder2 https://mywebsite.com/subfolder1
RedirectMatch 301 /subfolder1/subfolder2(.*)$ /subfolder1/$1
RedirectMatch 301 ^/subfolder1/subfolder2/?$ https://mywebsite.com/subfolder1
I have placed the "Options +FollowSymLinks" and "RewriteEngine on" rules before them, but NONE of them worked.
Can someone tell what's wrong and how to find the right rule?
Thank you.
Try this
RewriteRule ^subfolder1/subfolder2/(.*)$ /subfolder1 [R=301,NC,L]
With $1you attach the content of (.*) to the redirected URL. Remove them from code and
http://mywebsite.com/subfolder1/subfolder2/whatever-path
will be
http://mywebsite.com/subfolder1
I need to redirect from page
http://masterkanz.com.ua/index.php?route=product/category&path=79_103
to
http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
Rule like
Redirect 301 /index.php?route=product/category&path=79_103 http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
doesnt works. I read that problem can be in symbol "?". But what should I do?
Try this,
RewriteEngine On
RewriteCond %{QUERY_STRING} ^route=product/category&path=79_103$
RewriteRule ^index\.php/?$ http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye? [R=301,L]
I've tried this and it is working, you need to use {QUERY_STRING} to get the rule working.
I hope this helps.
i´m trying to do a 301 redirect in my .htaccess with the following lines:
Options +FollowSymLinks
RewriteEngine On
Redirect 301 /oldpage http://www.myhomepage.de/newpage/
The problem is, that the redirected url looks like this:
http://www.myhomepage.de/newpage/?it=oldpage
and that naturally causes a 404 on my site.
Does anybody know, what the problem could be?
Thanks a bunch!
This should work for you:
RewriteRule ^oldpage$ newpage? [R=301,L]
The question mark at the end of the destination will tell it to use a blank query string.
The above assume the pages are on the same domain. But if you're moving to another domain, this should do the trick:
RewriteRule ^oldpage$ http://newdomain.tld/newpage? [R=301,L]
This seems so trivial but I can't seem to get it to work. I'm trying to redirect
http://website.com/something/file.php?var=1
to
http://website2.com/something/$1/
I've tried a bunch of things the latest was
Redirect 301 ^file.php\?var=([0-9]+)$ http://website2.com/something/$1/
I've even tried doing
Redirect 301 ^something/$ http://website2.com/something/1/
but that didn't work either. The only thing that I've gotten to work is a redirect on the whole site doing
Redirect 301 /$ http://website2.com/something/1/
Is there something I'm missing? I've done a lot of redirects in my day but this one is throwing me for a loop. I've even used htaccess checker that said my url matches my string but it didn't actually do anything.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /something/file\.php\?var=(\d+) [NC]
RewriteRule ^ something/%1? [R=302,L,NE]
RewriteRule ^something/(\d+)/?$ something/file.php?q=$1 [L,QSA,NC]
I'am trying to update .htaccess to redirect me from : page.php/name to page.php?id=name. Can anyone help with example? I find a lot of example but not for this case.
To redirect (telling the browser that the request for page.php/name is at page.php?id=name, thus changing the URL in the location bar) you can do one of two things.
Using mod_alias:
RedirectMatch 301 ^/page\.php/(.*)$ /page.php?id=$1
Or using mod_rewrite:
RewriteRule ^/?page\.php/(.*)$ /page.php?id=$1 [QSA,L,R=301]
If you don't want a permanent redirect (301), then remove the 301 and =301 parts from the above.