.htaccess RewriteRule to preserve url parameters - .htaccess

I have some trouble with the .htaccess to convert the parameters into a normal url.
For domain.com/artikel.php?url=title, I want to visit it with domain.com/artikel/title.
My htaccess rewrite is as follows:
RewriteEngine On
RewriteRule ^artikel/([^/]*)$ /artikel.php?url=$1 [L]
Can you help me?

Related

User friendly URL through .htaccess

My url looks like -
http://localhost/user_notes/?id=1234.
I want to be turn it into user friendly url like
http://localhost/user_notes/1234
My .htaccess file looks like -
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
RewriteRule ^(.+)$ /user_notes/?id=$1
</IfModule>
The problem is with RewriteRule ^(.+)$ /user_notes/?id=$1
For more info see my directory structure
Note : In my directory structure there is also a public folder. But I can access files without including public in URL through htaccess file (line 3).
Could you please place these rules at top of your htaccess file(I hope there are NO redirect rules for https in your htaccess file). Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^ public%{REQUEST_URI} [L]
RewriteRule ^(user_notes)/(.*)/?$ $1/?id=$2 [NC,L]

Rewrite a URL via htaccess

I have a URL in the following structure like
http://www.naturaflowers.com/100-fresh-cut-wholesale-flowers.html
I want to rewrite the URL like
http://www.naturaflowers.com/fresh-cut-wholesale-flowers.html
We used "ultimate SEO url Plugin" to generate SEO friendly URL. The old URL structure is /index.php?main_page=index&cPath=category_id . My htaccess code is as follows :
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-(.*).html$ index\.php?main_page=index&cPath=$1&%{QUERY_STRING} [L]
The above mentioned plugin and this htaccess code rewrite
index.php?main_page=index&cPath=100 to
/100-fresh-cut-wholesale-flowers.html . And now I want to
/100-fresh-cut-wholesale-flowers.html rewrite to
/fresh-cut-wholesale-flowers.html everywhere in my website through
htaccess .
Have your rules like this:
RewriteEngine On
RewriteBase /
RewriteRule ^[0-9]+-(.+?\.html)$ /$1 [L,R=302,NC]
RewriteRule ^(.+?)\.html$ index\.php?main_page=index&cPath=$1 [L,QSA,NC]
RewriteRule ^(/?)\d+-(.*)$ $1$2

rewrite rule sub directory using .htaccess

I need help with url redirection e.g.
old url http://www.example.com/sub-dir/index.php?id=1
to new url
http://www.example.com/sub-dir/1/
can anyone help please I need the .htaccess code file to be in /sub-dir/ folder
Here is the code that I was trying to use:
RewriteRule ^/([0-9]+)/$ index.php?id=$1 [NC,L]
But it didn't work.
You can use this rule in /sub-dir/.htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /sub-dir/
RewriteRule ^([0-9]+)/?$ index.php?id=$1 [QSA,L]

url cleanup with .htaccess rewrite mode url cleanup

i have htaccess problem.
i want use htaccess rewrite mode for change this url:
http://somedomain.com/?id=https://play.google.com/store/apps/details?id=com.supercell.clashofclans
to this:
http://somedomain.com/?id=com.supercell.clashofclans
I've folowed some .htaccess tutorials but I couldn't. How can I make it work?
This should work for you:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=(.*)?id=(.*)
RewriteRule ^$ /?id=%2 [L,R=301]

.htaccess redirect to a different subdomain

Please i need help to create a correct instruction in .htaccess to redirect old urls done in this way:
/it/cartelle/465-piquadro-signo-cartella-ca1744si.html
to
/it/valigeria/cartelle/465-piquadro-signo-cartella-ca1744si-ca1744si.html
in other words we have shifted all category cartelle under category valigeria.
Our .htaccess at the moment is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.it$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
Anyone can help me?
Thanks
You can try this if you want to redirect to a new URL:
RedirectMatch /it/cartelle/(.*) /it/valigeria/cartelle/$1
If you want to keep the old url and just do an internal redirect:
RewriteRule ^/it/cartelle/(.*)$ /it/valigeria/cartelle/$1 [NC,L]

Resources