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]
Related
starting url - example.com/vid.php
wanted url - example.com/video
any help, pls, to write the RewriteRule
RewriteCond %{THE_REQUEST} /vid\.php\s [NC]
RewriteRule ???
With your shown samples, please try following htaccess rules file. Make sure to clear your browser cache before testing your URLs.
Also make sure that your vid.php file is present alongside with htaccess rules file.
RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/vid\.php\s [NC]
RewriteRule ^ video? [R=301,L]
RewriteRule ^video/? vid.php [NC,L]
You don't even need a separate RequestCond here...
RewriteEngine on
RewriteRule ^/?vid\.php$ /video [QSA,R=301,L]
RewriteRule ^/?video/? /vid.php [QSA,END]
Test with a fresh anonymous browser window.
It is a good idea to start out with a R=302 temporary redirection and only change that to a R=301 permanent redirection once you are satisfied.
How can I add the Google translate parameter #googtrans(en|de) or other language, so the translation happens automatically?
Basically, when the user goes to https://example.com/page/?lang=de they are redirected to https://example.com/page/?lang=en#googtrans(en|de)
I use this .htaccess rule, but it's not working:
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$
RewriteRule ^/?lang=en#googtrans(en|[a-z]{2}) [R=301,L]
EDIT: Adding edited Rules here.
RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/page/?\?lang=([a-z]{2})\s [NC]
RewriteRule ^ page/?lang=%1#googtrans(%1) [R=301,L,NE]
With your shown samples(this is considering that you are hitting URL like: https://example.com/page/?lang=de in browser), please try following .htaccess Rules file. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$ [NC]
RewriteRule ^page/?$ page/?lang=%1#googtrans(%1) [R=301,L,NE]
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]
How can i remove a file name in url with mod_rewrite.
ex: searchpage-some+search.html in to some+search.html
This is my .htaccess code code.
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /searchpage\.php\?search=(.*)\ HTTP
RewriteRule ^searchpage\.php$ /searchpage-search-%2.html? [R,L]
#Internal rewrite
RewriteRule searchpage-search-(.*)\.html$ searchpage.php?search=$1 [L]
This is for a search form that uses $_GET request. This works well only thing is that i want to remove the file name. I would really appreciated if anyone can help out.
In your example you have searchpage-some+search.html but in your htaccess you are actually rewriting it to searchpage-search-some+search.html.
But to remove the searchpage-search from links, just remove searchpage-search- from the RewriteRule. Your htaccess would be something like
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /searchpage\.php\?search=(.*)\ HTTP
RewriteRule ^searchpage\.php$ /%2.html? [R,L]
#Internal rewrite
RewriteRule (.*)\.html$ searchpage.php?search=$1 [L]
I've wrote .htaccess file to convert urls to SEO friendly :
the original url is :
http://palestinianz.com/?page=person&p=Alex-Atalla
the content of .htaccess is :
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /?page=person&p=$1 [L]
it should produce a link like this :
http://palestinianz.com/Alex-Atalla.html
But it makes no effect although I put the file in the root of my website !
where is the problem ?
If you want the URL to change in the address bar, you need to redirect the browser, then rewrite on the server. The first part of this answer explains the process that you want: https://stackoverflow.com/a/11711948/851273
So looking at the second list, the process is to redirect the browser if an ugly link is request to a nice looking link:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?page=person&p=([^\ ]+)
RewriteRule ^$ /%1.html? [R=301,L]
Now, on the server end you need to internall rewrite it back to the ugly url, which is more or less what you already have:
RewriteRule ^([^/]*)\.html$ /?page=person&p=$1 [L]
You can try:
RewriteCond %{REQUEST_URI} (.+)\.html$
RewriteRule ^(.+)\.html$ ./index.php?page=person&p=$1 [L]
Only problem with this is any .html page will go through this. May want to change to the following:
# URL: domain.com/person/Alex-Atalla.html
RewriteCond %{REQUEST_URI} (.+)/(.+)\.html$
RewriteRule ^(.+)/(.+)\.html$ ./index.php?page=$1&p=$2 [L]
This will allow you to have more robustness in changing the the page variable as well