htaccess redirect with L-flag? - .htaccess

I want a user, that tries to reach somedomain.com/somethingold (with or without www) to be redirected to www.somedomain.com/somethingnew. Normally I'd just use a simple Redirect rule, but I also don't want any other following rules to be applied. I guess for that we have the L-flag, but that doesn't work with a simple Redirect, but only with RewriteRule. Is that correct? So how would I write it then?
Thanks for any help.

Related

Using htaccess to redirect URL from one query string to another

I need to redirect
from
/showthread.php?tid=6
to
/viewtopic.php?t=6
using htaccess. We moved from MyBB to PhpBB and would like to safe links leading to our site.
The domain remains the same. All my attempts failed.
Can someone help?
^showthread.php?tid=(\d+)$ viewtopic.php?t=$1
This should do the trick with htaccess redirect parameter :)

QR code printed with wrong url. .htaccess redirect?

The issue is our marketing department printed the wrong QR code and the url www.batesvr.com\longcreek. Notice the . QRcode reader browser does not autocorrect the \ to a /. Is there a way in my .htaccess file to correct this issue so we don't have to reprint?
I believe it's worth trying to fix this rather than reprinting everything.
You can fix the '.' issue using the following .htaccess redirect.
RewriteEngine on
//301 Redirect
Redirect 301 /longcreek. /longcreek
Try adding this rule and check the URL. Depending on a device/browser backward-slash might be replaced with a forward-slash automatically. If not, it might be worth trying adding another redirect rule as well.
At the moment www.batesvr.com seems to be down (500 error), so if it's your real website, you might route all the traffic to the actual page. It would be a hack, but might do the trick for now.
Let me know what worked and what didn't.

.htaccess redirect to page within folder leads to repeating url segments

I'd like to do the reverse of this issue. I am trying to redirect users from a subfolder to a child page. This is my current rule that doesn't work:
Redirect 302 /boston /boston/info
Using this, if I go to example.com/boston, I get redirected to example.com/boston/info/info/info/info/info/info... and it keeps going.
I imagine I'll need to switch to a RewriteRule in order to prevent this duplication. How should I go about this?
"/boston/info" - This should be the full URL you are redirecting too.
eg. www.website.com/boston/info

htaccess URL redirect based on page title

I would like to add a line to my htaccess to change this url:
RewriteEngine on
do this is the url
http://site/Calendar/viewevent?eventid=9223
into something like this :
http://site/Calendar/viewevent/Title-of-event
its php and joomla and I am a php developer, please dont advise me to use a component or module to handle redirects, I am trying to achieve this using .htaccess ONLY :) thank you in advance!!
Your 'pretty' url contains information that is not in the 'working' url. Besides that, the 'working' url also contains information that is not in the pretty url. You need database access to translate the event id to a seo-title, and the seo-title back to an event id. In other words: It is impossible to do this with .htaccess only, unless you change 'viewevent' to accept an event by seo-title, instead of eventid.
Mod_dbd can possible be used, but only in the server config file, not .htaccess.
As Sumurai8 says htaccess cant transform url like you want automatically.
But you can use Redirect 301 (or its variation) for one url to another.
for your example:
Redirect 301 /Calendar/viewevent?eventid=9223 /Calendar/viewevent/Title-of-event
more information here

.htaccess Redirect Issue , struggling with parameters

I am struggling with an url/parameter issue.
The main index.php page of my website was previously used for e.g.
www.domain.com/index.php?site=3&word=21 and
www.domain.com/index.php?site=3
But now I have changed those things, but in Google the URLs are still listed. So what I need is to redirect all the type of pages above to the main page/domain www.domain.com.
I believe .htaccess redirect is the right thing to use then, is that correct?
What type of code do I need to redirect those to main domain. Just the url's with parameters after index.php? etc. not other directories e.g. www.domain.com/sunshine/
Would be great if someone could help me with this. I believe it is actually a quick fix, but I have failed to get the code correct.
Thanks.
You can add this to an .htaccess in your site root:
RedirectMatch permanent ^/index.php* http://www.domain.com/
But, be careful if your new index page is also named index.php because you might run into a redirect loop.

Resources