Redirect only certain paths - .htaccess

I need to redirect only some pages to make the URL neater, such as:
Original : http://www.mywebsite.com/form.php
What I want : http://www.mywebsite.com/form AND http://www.mywebsite.com/form/
How do I write the htaccess file for that?

I have not tested but something like this should work:
RewriteEngine On
RewriteRule ^form.php(/)?$ http://www.mywebsite.com/form$1 [L]

Related

How to add a rewrite rule to remove paramaters in htaccess? [duplicate]

I Want to rewrite the url using .htaccess
Plz Read the code, and you well Get to know What I mean
My URL :
article.php?id=1&title=example
Using this in .htaccess
RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+)$
article.php?id=$1&title=$2 [NC,L]
I get
article/1/example
What i need is
article/example
So something like this:
RewriteRule ^article/([0-9a-zA-Z_-]+)$ article.php?title=$1 [NC,L]

How do i URL rewrite using .htacess

i need some help rewriting URL using .htaccess my urls looks like:
http://www.example.com/testro2/product.php?id=426834&productStore=396
And i need have it work with text into it, example:
http://www.example.com/testro2/product/{anythinghere}/id=4268334&productStore=369
or you can make it look more clear like removing id= and &productStore= will be great, else i can use with them. example
http://www.example.com/testro2/product/{anythinghere}/4268334/396
The thing is that i need to have my keyword anythinghere in the URL.
Also, i would like to rewrite
http://www.example.com/testro2/search.php?q=shoes
TO
http://www.example.com/testro2/search/shoes
You can put this code in your /testro2/.htaccess
RewriteEngine On
RewriteBase /testro2/
RewriteRule ^product/.+/(\d+)/(\d+)$ product.php?id=$1&productStore=$2 [L]
RewriteRule ^search/(.+)$ search.php?q=$1 [L]

url redirection with get parameter Apatche htaccess

Hello I have a url that is like that :
www.mysite.com/activation.php?token=d4ba10b14dedc7e7e7338ee8251670fa
What I would like to have is something like that :
www.mysite.com/Activation/Token/d4ba10b14dedc7e7e7338ee8251670fa
How can I do that please
You can put this rule in your htaccess (which has to be in root folder)
RewriteEngine On
RewriteRule ^Activation/Token/([^/]+)$ /activation.php?token=$1 [L]

Replace / mask word in URL using htaccess

I have a site which has a url structure like so:
url/example1/sometext
So I dont have to go through and change a crazy amount of code, can I use htaccess to do the following?
url/newword/sometext redirects to: url/example1/sometext with url/newword/sometext still shown the address bar.
I have tried some rewrites like:
RewriteRule ^(.*)example1(.*)$ url/$1newword$2 [R=301,L]
Any ideas?
As long as the "url" part is still the same, then you can just get rid of the R=301 flag:
RewriteRule ^(.*)example1(.*)$ /$1newword$2 [L]

rerwrite url in .htaccess

I want to make the old urls point to the new pages. I'm having trouble because the old URL looks like this: http://nilandsplace.com/store/camping_eng/coghlans-campfire-cooking-forks-toaster-forks-package-of-4.html.
I want to do a URL re-right in .ht access from mywebsite.com/camping_eng/some.html to mywebsite.com/camping/some.html, were the "some.html" part is identical.
Only camping_eng changes to camping.
You might want to try this:
RewriteEngine on
RewriteRule ^camping_eng/([a-zA-Z0-9-=_.]+)/?$ http://mywebsite.com/camping/$1 [L,R=301]
This example works according to your question:
from mywebsite.com/camping_eng/some.html
to mywebsite.com/camping/some.html were the "some.html" part is identical.
RewriteEngine on
RewriteBase /store
RewriteRule ^camping_eng/(.*)$ camping/$1 [QSA,L,R=301]

Resources