Htaccess. Redirect from non-friendly Url - .htaccess

I need friendly URL only for some pages on my website, I added this code to htaccess
RewriteEngine On
RewriteRule languages/english-online.html languages/english.php
And now when I open in browser http://mydomain.com/languages/english-online.html I see the content of page "languages/english.php". It's OK
But I also want to do: if somebody tries to enter to http://mydomain.com/languages/english.php, he will be redirected to http://mydomain.com/languages/english-online.html
I've tried everything, I get or 500 error or nothing happends.
Please help

Did you try:
Redirect /languages/english.php http://mydomain.com/languages/english-online.html
Similar code worked for files on my own website.

Related

Redirect a Rewrite URL Address

Adding this to my .htaccess file works to shorten the URL and get rid of the .shtml bit.
RewriteEngine On
RewriteRule about about.shtml
But, the original address http://xxx/about.shtml also still exists. I don't want Google or anyone to see that one, so I tried redirecting it to the rewritten URL:
Redirect 301 /about.shtml /about
This gives an error on Firefox that it's not working and on Google that it is being redirected too many times. Maybe it's going in some sort of a loop.
I don't want the original file to show up anywhere in the web address (with the.shtml ending), so not sure what else besides a redirect to do.
Thanks!

Mod Rewrite rewrite URL weird behavior, keeps adding query string to displayed URL

I'm a beginner.
What I want
the request URL .../activity/1415/abcdefgh/ to be rewritten to .../activity/gallery.php?k=abcdefgh
but still display the URL to the visitor as .../activity/1415/abcdefgh/.
But when I try, the URL .../activity/1415/abcdefgh/ turned to .../activity/1415/abcdefgh/?k=abcdefgh.
The page displays fine, but I want to hide the query.
Basically what happened
Link says: http://localhost/activity/1516/iolfpqwx
Clicked link
Address bar says: http://localhost/activity/1516/iolfpqwx/?key=iolfpqwx, which I don't want.
My entire .htaccess in the activity/ directory:
RewriteEngine On
RewriteRule ^(\d{4})/(\w{8,})(?:/([\w\s]+)?)?$ gallery.php?key=$2 [L,QSA,NC]
My Specs:
XAMPP on Windows with Apache
What I know
I have not setup any redirect rules on my testing server, so I don't believe I have any [R] flags.
I have a similar .htaccess in an adjacent directory with the code RewriteRule ^settings/([^/]+)/*$ index.php?p=settings&s=$1 [L,QSA,NC] and it didn't show me query strings.
I've Googled my issue, but cannot find a solution. Please help.

Redirect the URL using .htaccess

I have a page showing the products with the hyperlink for it as
www.domainname.com/productname
now my client needs to add store and needs the URL to show as
www.domainname.com/store/productname
I have done it via code and now when I click on it for a detail page, its still redirecting to
www.domainname.com/productname
but need to be
www.domainname.com/store/productname
tried with this: RewriteRule ^store/?$ domina.com/?$ [NC,L] in .htaccess file, not sure whether I'm on page
Can any one tell me how to do it via .htaccess file.
Thanks in advance.
Try this :
RewriteRule ^store/(.*)/?$ http://domain.com/store/$1 [R,L,NC]

Redirect Loop after adding a code to .htaccess

I tried to put a redirect in a my website for CEO (Search Engine Friendly )
i put a code in .htaccess , then i checked here http://www.webconfs.com/redirect-check.php , so it said : (Found redirect to http://www.abosurfmorocco.com/. The Redirect is Search Engine Friendly.), but when i went to the website i got a Redirect Loop error in the browser, i deleted this code in .htaccess, i cleaned browser cookies , but i still can get to the website.
is there is way to resolve this problem , please
I think there is still a 301 Redirect. Check again if there isn't any .htaccess file.
Moved Permanently: http://www.abosurfmorocco.com/ --> http://www.abosurfmorocco.com

seo friendly url and redirect

I finally found a way to remove get parameters from my urls
i had url like
/s.com/file.php?name=somthing
with this code i changed them to s.com/file/somthing
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^file/(.*?)$ http://s.com/file.php?name=$1
so far everything is ok
in my local host when i click on a url like s.com/file/somthing it goes exactly to the url
but in my server it redirects to old url and shows old url
i dont want to display my old url
can someone help?
http redirects are always external => visible in the browser. Try that:
RewriteRule ^file/(.*?)$ /file.php?name=$1

Resources