I do have thousand of clients that have received a bad URL, and I am trying to rewrite it without success.
The bad url sent was:
http://www.123456.cl/123456-abcde/webapp/wcs/stores/servlet/OrderDetailUserGuestView?storeId=10151&catalogId=10051&langId=-5&orderId=22172008&rut=10946497K
And the rewrite should redirect to:
http://www.123456.cl/webapp/wcs/stores/servlet/OrderDetailUserGuestView?storeId=10151&catalogId=10051&langId=-5&orderId=22172008&rut=10946497K
Without the 123456-abcde
All the contents after the view OrderDetail are dynamic.
Do you guys have any idea?
Did you use the right flags? And set a base?
RewriteEngine on
RewriteBase /
RewriteRule ^123456-abcde/(.*) $1 [L,R=301]
Try it without the =301 (permanent) part, first. If it goes to the right place, make it permanent.
Related
I have a file at example.com/DesktopModules/SubscriptionSignup/Tools/IPNHandler.aspx that needs to be rewritten so that it actually runs example.com/paypal-ipn-handler.php.
All other traffic, though, should be redirected to another-example.com.
I'm using this in my .htaccess file:
# Rewrite IPNHandler.aspx to paypal-ipn-handler.php
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/Tools/IPNHandler.aspx [NC]
RewriteRule ^.*$ https://www.example.com/paypal-ipn-handler.php [P]
</IfModule>
#Redirect all other traffic to new domain.
RewriteRule ^ https://www.another-example.com%{REQUEST_URI} [L,R=301]
However, that's redirected everything including the URL that should stay at this domain, but get re-written to the PHP file.
For example, with the above in place, I would expect that traffic to example.com/DesktopModules/SubscriptionSignup/Tools/IPNHandler.aspx would remain at example.com, but run the PHP script instead. This is not happening, though. It's getting redirected to another-example.com/..../IPNHandler.aspx and gives me a 404, of course.
Any information about how I can adjust this so that my rewrite works and stays on the original domain, but all other traffic gets redirected would be greatly appreciated. Thanks!
EDIT
Actually, I commented out the redirect to see if my rewrite was working, and it's actually giving me a 404, but when I hit the paypal-ipn-handler.php directly I get the output I expect.
So it seems I need more help than I thought, please, and thanks!
You may use these rules in your site soot .htaccess:
RewriteEngine On
RewriteRule Tools/IPNHandler\.aspx$ /paypal-ipn-handler.php [L,NC]
#Redirect all other traffic to new domain.
RewriteRule !^paypal-ipn-handler\.php$ https://www.another-example.com%{REQUEST_URI} [L,NC,NE,R=301]
There is no need to use P flag here as you just want an internal rewrite.
Condition !^paypal-ipn-handler\.php$ will redirect everything except /paypal-ipn-handler.php.
Make sure to use a new browser to test or test after you completely clear browser cache.
How is possible in .htaccess to make from subdomain
example.domain.com/gallery/index.html
into example.domain.com/gallery/
Not sure what you are trying to say with your last comment to the question. The rule I posted rewrites exactly one URL. But maybe you are looking for the opposite redirection, I just realize, so:
RewriteEngine on
RewriteRule ^/?gallery/index\.html$ /gallery/ [R=301]
RewriteRule /?gallery/?$ /gallery/index.html [END]
This redirects clients requesting /gallery/indx.html but still delivers the local file /gallery/index.html when requesting /gallery.
1st i have to say: i tried google of course. so many tips about my request - but i dont get it. maybe you can help...
it sounds simple: i want a 301 via .htaccess to a another parameter file
for example:
www.mydomain.tld/ runs without .htaccess to www.mydomain.tld/index.php?de_xyz
but:
what i want is, if you call www.mydomain.tld you get to www.mydomain.tld/index.php?en_xyz
-> ?de to ?en
if i try a simple: Redirect 301 /index.php http://www.mydomain.tld/index.php?xyz i get a redirection error on this side.
i have tried so many ways. dont get it :/
thx for your answer
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)en_xyz(&|$) [NC]
RewriteRule ^/?$ %{REQUEST_URI}?en_xyz [L,QSA,R=302]
Have you tried
RewriteRule ^/?$ /index.php?en_xyz [R=301]
Note that 301 is a permanent redirect so the browser might not re-read your configuration if you redirect to a wrong address by mistake while trying.
If not working you might want to add
RewriteLog "/some/path/rewrite.log"
RewriteLogLevel 3
to your vhosts file if you have access (it might not work in .htaccess) and get the details from log.
By the way I'd prefer handling this in index.php:
header('Location: index.php?en', true, 301);
I've taken my site down for some prolonged maintenance and am using mod_rewrite to send all requests to a single page: www.mysite.com/temp/503.php
This is my .htaccess file which works fine.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/temp/503.php [NC]
RewriteRule .* /temp/503.php [R,L]
However, what I'd also like to be able to do is to hide /temp/503.php in the resulting URL from the visitor.
I know this is perhaps trivial and I'm sure fairly simple to achieve, but with my limited mod_rewrite skills I can't seem to get it to work.
Any help would be much appreciated.
Thanks.
Just get rid of the R flag in the rewrite rule, which tells the rule to redirect the request, thus changing the URL in the browser's location bar. So the rule would look like:
RewriteRule .* /temp/503.php [L]
which internally rewrites the requested URI instead of externally telling the browser that it's been moved to a new URL.
Sorry for the long title. I'm currently writing some 301 redirects and using mod rewrite (Apache) to handle them. Currently only one of the two 301s I have tried is working. Here is the code:
#301 REDIRECTS
RewriteEngine On
RewriteRule ^Fox-and-Frank-home\.html$ http://www.mydomain.co.uk/contact_us.php [R=301]
RewriteRule ^about\.html$ http://www.domain.com/about/ [R=301,L]
about.html properly redirects, but Fox-and-Frank-home.html does not. I have tried this with other names, other URLs, but it is not working. Any help will be greatly appreciated.
EDIT
I have gotten this to work on a completely bare .htaccess file. Do 301 redirects need to be at the very top before everything else?
You don't have a L (last) flag on your Fox-and-Frank rewrite, so other rules can potentially be processed, and definetly will be in a .htaccess (where you need to use the END flag).
Try changing it to:
RewriteRule ^Fox-and-Frank-home\.html$ http://www.mydomain.co.uk/contact-us.php [NC,R=301,L]
Where:
NC makes it a case insensitive check (so fox-and-frank-home would
redirect to)
R=301 is the 301 redirect (although you can just put R
and 301 would be assumed I always specify it personally)
L tells
mod_rewrite to stop processing further rules (but as its in a
.htaccess. you may need to use END instead - see http://httpd.apache.org/docs/current/rewrite/flags.html#flag_l).
Regards.