.htaccess url rewrite not working - .htaccess

here i am trying to rewrite url but its not working
> Options +FollowSymlinks RewriteEngine on rewriterule
> ^FAQ.php?view=why_best(.*)$ http://www.bestsports.ca/FAQ/WhyBest$1
> [r=301,nc]
old url is http://www.bestsports.ca/FAQ.php?view=why_best
New Url http://www.bestsports.ca/FAQ/WhyBest should be like this
after editing htacces fiel its opening the same old url please help
thanks
i am trying this code now
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+FAQ\.php\?view=why_best [NC]
RewriteRule ^ /FAQ/WhyBest/? [R=301,L]
RewriteRule ^FAQ/WhyBest/?$ /FAQ.php?view=why_best [QSA,NC,L]
RewriteRule ^ /FAQ/SizeChart/? [R=301,L]
RewriteRule ^FAQ/SizeChart/?$ /FAQ.php?view=size_chart [QSA,NC,L]
but its showing error
The page isn't redirecting properly
and if i click same link again for FAQ.php?view=why_best its
redirected to
http://www.bestsports.ca/FAQ/WhyBest/FAQ.php?view=why_best
as you helped me i completed the above seo url rewrite problem for my all other website pages
i used the third party cart system from ecwid when i click on any proudct its show this link or url
http://www.bestsports.ca/product.php#!/~/product/category=9414048&id=11484861
how can i rewrite this url insted of showing category id and i want to show name
i already tried your above instruction but its not working can you please explain is it possible to make this url seo friendly url
thank you

You cannot match query string in RewriteRule. Use RewriteCond instead:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+FAQ\.php\?view=why_best [NC]
RewriteRule ^ /FAQ/WhyBest? [R=301,L]
RewriteRule ^FAQ/WhyBest/?$ /FAQ.php?view=why_best [QSA,NC,L]

Related

How to write htaccess rewrite rule for change link

i'm searching for rule for change link in htaccess.
Currently the link looks like this:
localhost.com/forum/profile.php?id=1
And this is the effect I would like to achieve:
localhost.com/forum/profile/1
I added the following rules:
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/forum/profile\.php\?id=([0-9]+)\s [NC]
RewriteRule ^ /forum/profile/%1? [R=301,L]
The problem is that the page automatically redirects to the expected link, but a 404 error is returned
You need one more rule to map forum/profile/123 to forum/profile\.php?id=123. Please clear your browser cache before testing your URLs.
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/forum/profile\.php\?id=([0-9]+)\s [NC]
RewriteRule ^ /forum/profile/%1? [R=301,L]
RewriteRule ^forum/profile/([0-9]+)/?$ /forum/profile.php?id=$1 [NC,QSA,L]

Seo friendly url - Unable to find a way to get the htaccess to rewrite the urls

Currently, my site has this url format:
https://example.com/blog/news.php?read=article-title-here
I would like to change this url to:
https://example.com/news/article-title-here
Any idea how to do this please? I tried this method but see no changes in the browser bar(even after emptying the cache):
RewriteCond %{QUERY_STRING} ^read=(.*)$
RewriteRule ^news/?$ %1.php? [R=301,L]
Also, where should the htaccess file be written?
in https://example.com/
or
https://example.com/blog/
Thank you in advance!
Ben
You can use in your https://example.com/.htaccess:
Options -MultiViews
RewriteEngine on
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+blog/news\.php\?read=([^\s&]+) [NC]
RewriteRule ^ /news/%1? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^news/(.+?)/?$ blog/news.php?read=$1 [L,QSA,NC]

.htaccess rewrite rule with get params

I need to be able to rewrite http://example.com/staging/details/?postid=23 so that it becomes http://example.com/staging/grandhotelterduin
I am not sure how the .htaccess rule should be?
I have came up with something like this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC]
I am not sure I am doing this correctly, can you plz help
I want it such that the http://example.com/staging/grandhotelterduin/ get redirected to http://example.com/staging/details/?postid=23 but the url that appears in the browser is `http://example.com/staging/grandhotelterduin
Use this:
RewriteEngine On
RewriteRule ^grandhotelterduin$ /staging/details/?postid=23 [L]
It will give you the following URL:
http://sheetz.nl/grandhotelterduin
EDIT:
RewriteCond %{THE_REQUEST} /staging/details/?postid=([0-9]+) [NC]
RewriteRule ^ /staging/grandhotelterduin [L,R]

Redirect url without changing the url

I know there are a lot of answers available for this but none of them worked for me. I am stuck with this very familiar issue. I have made a website wherein i have to make customised urls for all my franchisees. But all these customised urls should take back to homepage.
Eg. if franchisee enters following url : www.example.com/franchisee/john it should redirect the franchisee to www.example.com but the browser url should remain www.example.com/franchisee/john
I have tried this by modifying .htaccess file but it shows page not found(404) error. Any help will be appreciable. I am new to .htaccess.
Here is .htaccess code :
RewriteCond %{REQUEST_URI} ^.*/franchisee/[a-zA-Z0-9_\.\-]+$
RewriteRule ^(.*)$ / [P]
EDIT :
Here is the complete .htaccess file. This file is present under the docroot folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
Options +FollowSymLinks -MultiViews
RewriteCond %{REQUEST_URI} ^/franchisee/[a-zA-Z0-9_\.\-]+$
RewriteRule ^franchisee/[\w.-]+/?$ / [L]
</IfModule>
You don't need to use proxy or P flag here. Use this rule without R flag to silently rewrite to /:
RewriteEngine On
RewriteRule ^franchisee/[\w.-]+/?$ / [L]

Making URL different from orginal

My site is: http://binodgiri.com.np, when you click on link you are redirecte to: http://www.binodgiri.com/what.php?id=1
I want to display above url as
http://www.binodgiri.com.np/change-url/
I tried following on .htaccess file
RewriteEngine On
RewriteRule ^change-url/(.*)$ what.php?id=1 [L]
(I don't have much knowledge on this stuff.)
Try this, it should redirect http://www.binodgiri.com/what.php?id=1 to http://www.binodgiri.com.np/change-url/
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /what\.php\?id=1\ HTTP
RewriteRule ^ /change-url\? [R,L]

Resources