Htaccess rewrite clean categories & articles - .htaccess

I have a URL that looks like this:
example.com/index.php?p=blog&category=blog&article=blog-test
But I'd like to have it look like:
example.com/blog/blog/blog-test
How would I be able to do this with htaccess?

You can use .htaccess:
RewriteEngine on
RewriteRule ^(.+?)/(.+?)/(.+)$ index.php?p=$1&category=$2&article=$3 [L]

Related

htaccess add sufix to year. /wp-content/uploads/year-sufix/01/file.jpg

could you help me to rewerite urls?
Now urls looks like:
src="https://example.com/wp-content/uploads/2022/02/file1.png"
src="https://example.com/wp-content/uploads/2019/02/file2.png"
src="https://example.com/wp-content/uploads/2020/02/file3.png"
I'd like them to look like this:
src="https://example.com/wp-content/webp-uploads/2022/02/file1.webp"
src="https://example.com/wp-content/webp-uploads/2019/02/file2.webp"
src="https://example.com/wp-content/webp-uploads/2020/02/file3.webp"
i try something like this, but didn't work :C
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-content/uploads/.+?\.(jpe?g|png|gif)$ /wp-content/webp-uploads/.+?\.webp$ [R=301,L]
</IfModule>
unfortunately htaccess gives me a lot of trouble and I don't know how to write it :/

htaccess to remove part of a url, .htaccess

I was wondering how it is possible to remove part of a url with htaccess for example I have a url like this:
http://localhost/item.php?pa=gd34392
now I need to use htaccess to redirect this page or anything like this to a page with this url:
http://localhost/gd34392
I have tried things like this but nothing seems to work and I do not really know my way around htaccess
RewriteEngine on
RewriteRule item.php?pa=$1 /$1 [R=301,L]
You can achieve that using the following rules in your .htaccess:
RewriteEngine On
RewriteRule ^([^/]*)$ /item.php?pa=$1 [L]
Just make sure you clear your cache before testing this.

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]

mod_rewrite clean urls with alphabets

I was using mod rewrite to create clean urls. I have urls like this :
http://www.sitename.com/viewcategory.php?id=262
I have rewritten successfully my url like this :
http://www.sitename.com/262
With the following mod_rewrite rule
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ viewcategory.php?id=$1
RewriteRule ^([a-zA-Z0-9]+)/$ viewcategory.php?id=$1
What i want is to display the category name somthing like this:
http://www.sitename.com/categoryname
Please suggest me if there is a mistake in my rewrite rule or I need to do something else.
Thanks and regards.

URL Rewriting.htaccess

I want to rewrite a URL through htaccess, but I am not getting the solution to do the specific rewriting. For e.g., I have a URL:
http://www.yourdomain.com/page/about-us.html
Now I want to remove page from above URL, so it should look like;
http://www.yourdomain.com/about-us.html
Can anybody help me with this.
Thanks in advance.
Something like this should work:
RewriteEngine on
RewriteRule ^about-us.html$ /page/about-us.html
If you need it done on any URL put into the site, then something like this:
RewriteEngine on
RewriteRule ^([_\&\'\,\+A-Za-z0-9-]+).html$ /page/$1.html
Assuming you want a 301:
RewriteEngine on
RewriteRule ^page/about-us.html$ /about.html [R=301,L]

Resources