The goa is to rewrite:
www.example.com/fr/something.php ->www.example.com/something.php?lang=fr
I tried with:
RewriteRule ^.*/fr/(.*)$ http://www.example.com/$1?lang=fr[R,L]
RewriteRule \/fr\/(.*)$ http://www.example.com/$1?lang=fr[R,L,QSA]
RewriteRule /fr/(.*)$ http://www.example.com/$1?lang=fr[R,L,QSA]
Not good:
Any idea ?
Try with:
RewriteEngine on
RewriteRule ^fr/(.*)$ /$1?lang=fr [QSA,L]
I do not think you want a redirect, but only a rewrite (without changing the url)
Related
I have this url
www.mydomain.com/aftomelanomenes-sfragides/eos-7-grammes/197430-092399532491-sfragida-trodat-printy-4915-aytomelanomeni-mple-detail
and I would like to replace it with this
www.mydomain.com/aftomelanomenes-sfragides/eos-7-grammes/197430-092399532491-sfragida-trodat-printy-4915-aftomelanomeni-mple-detail
i tried this code to htaccess
RewriteRule ^-aftomelanomeni-?$ -aytomelanomeni-$1 [NC,L]
But it doesn't work
Try to use this pattern:
RewriteRule ^(.+)-aytomelanomeni-(.+)$ http://%{HTTP_HOST}/$1-aftomelanomeni-$2 [R=301,L]
I would like to write a rule, that would redirect URL like this:
myweb.com/en/page
to
myweb.com/page.php?lang=en
This code:
RewriteRule ^/(cz|en)/(.*)$ $2?lang=$1 [L]
does not work (error 404). Thanks everyone.
Try this following:
RewriteRule ^/(cz|en)/(.*)$ $2.php?lang=$1 [L]
You dont need to match the leading slash in RewriteRule's pattern on htaccess context :
RewriteRule ^(cz|en)/(.*)$ $2?lang=$1 [L]
i would like the url being rewritten automatically from :
hello.com/a-b-c/0/
to:
hello.com/a-b-c/1/
I have a rewrite rule on .htaccess
RewriteRule ([a-zA-Z0-9\.\-]+)/0/?$ $1/1/ [NC,L]
But that doesn't seem to work. may I know what is the issue?
Thanks.
You can try this rule for redirect:
RewriteRule ^([a-zA-Z0-9.-]+)/0/?$ /$1/1/ [R,L]
Or for internal rewrite:
RewriteRule ^([a-zA-Z0-9.-]+)/0/?$ /$1/1/ [L]
How to rewrite
/?custom_ref=
with
/?ref=
using htaccess rewrite???
RewriteEngine On
RewriteCond %{QUERY_STRING} custom_ref=(.*)
RewriteRule (.*) /?ref=%1 [R=301,L]
Can you please tell me the directory/file that you using this query on so I make sure this code will only work with it.
I have an issue with url rewriting, here's what I have so far:
Options +FollowSymlinks
RewriteEngine on
RewriteRule \.(gif|png|jpg|css|js)$|^index\.php$ - [L]
RewriteRule ^users/(.+)$ /profile.php?userid=$1 [NC]
RewriteRule ^(.+)/(.+)$ /main.php?region=$1&place=$2 [NC]
Basically, if the url is mysite.com/users/username I want it to use profile.php, then for anything else, to go to main.php.
However, with that code it doesn't happen as expected, it always uses main.php. Is there anyway you can use if and elses in htaccess, or something similar?
You're missing L flag from 2nd and 3rd rules. Have your code like this:
RewriteRule \.(gif|png|jpg|css|js)$|^index\.php$ - [L]
RewriteRule ^users/(.+)$ /profile.php?userid=$1 [NC,L,QSA]
RewriteRule ^(.+)/(.+)$ /main.php?region=$1&place=$2 [NC,L,QSA]