Rewrite rule in .htaccess and redirect - .htaccess

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]

Related

.htaccess: Replace part of url for a domain

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]

.htaccess : write rule with langage parameter for SEO

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)

how do I create a url rewrite in htaccess

I have a link: admin/tcpdf/examples/viewContract.inc.php?id=MTE4 and am trying to make a rewrite rule to just: /contract/
Would love some assistance with this!
This should do the trick
RewriteEngine On
RewriteRule ^/?admin/tcpdf/examples/viewContract.inc.php*$ /contact/ [R=301,L]
How to handle 404
RewriteRule ^/?error404\.php$ - [R=404]

user friendly URL rewrite rule

Could anyone advise on how to I can rewrite this url:
https://test.com/user/user.php?u=name
to
https://test.com/user/user/name
Please?
Below is my rewrite rule but it's not doing exactly what I want.
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/user/([^/]+) /user.php?u=$1 [L]
Thanks a lot
Try this:
RewriteEngine On
RewriteRule ^user/user/([^/]*)/?$ /user/user.php?u=$1 [L]

htaccess 301 redirect rule

I want to
redirect http://www.mysite.com/index.php?option=com_content&view=frontpage&Itemid=1
TO
http://www.mysite.com/
Can you please show me the 301 redirect rule for htaccess?
Thanks.
I tried the following, but no luck.
RewriteCond %{QUERY_STRING} ^option=com_content&view=frontpage&Itemid=1$
RewriteRule ^/index.php$ http://www.mysite.com [L,R=301]
You can try below configuration,
RewriteCond %{QUERY_STRING} option=com_content&view=frontpage&Itemid=1
RewriteRule index\.php$ /? [L,R=301]
I tried it on my domain and it works fine. Hope this works for you too... :)
According to www.htaccessredirect.net, the code to do this would be:
Redirect 301 /index.php?option=com_content&view=frontpage&Itemid=1 /
Alternatively, you could look in to using apache's mod_rewrite module.

Resources