How to pass multiple parameter in htaccess - .htaccess

I have created dynamic parameters, I passed two(ids and id) parameter in URL but do not know pass parameter in below htacces file could you solve this issue please
my htacces file:
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/store\.html\?ids=([0-9]+)&id=([0-9]+)\s [NC]
RewriteRule ^ /store/%1? [R=301,L]
RewriteRule ^store/([0-9]+)$ /store.html?ids=$1&id=$2 [L]
my URL is http://localhost/store.html?ids=kebab-bistro&id=196

Related

How to Rewrite URL in htaccess

I have URLs with two query parameters e.g. /skills/keywords/list.php?industry=retail&q=analyst and I'd like to redirect those URLs to /list-of-%2-skills-in-%1 .
I have tried the code below which looks at the query "industry" and "q" to build the destination URL: /list-of-%2-skills-in-%1
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^industry=(.*)&q=(.*)$ [NC]
RewriteRule ^skills/keywords/list\.php$ /list-of-%2-skills-in-%1? [L,R=301]
I'm expecting: /skills/keywords/list.php?industry=retail&q=analyst to redirect to /list-of-analyst-skills-in-retail which it does but I have a 404 content not found.
Can someone point me to the right direction please?
This is because the destination path /list-of-%2-skills-in-%1 doesn't exist on your server. You need to rewrite this path to the existent file /skills/keywords/list.php?industry=retail&q=analyst .
RewriteEngine On
RewriteBase /
#redirect /skills/keywords/list.php?industry=foo&q=bar
#to /list-of-bar-skills-in-foo
RewriteCond %{THE_REQUEST} /skills/keywords/list\.php\?industry=([^&]*)&q=([^\s]+) [NC]
RewriteRule ^skills/keywords/list\.php$ /list-of-%2-skills-in-%1? [L,R=301]
#rewrite new URL to the old one
RewriteRule ^list-of-([^-]+)-skills-in-([^-]+)/?$ /skills/keywords/list.php?industry=$1&q=$2 [NC,L]

htaccess redirect weird url target.how to fix this?

I am trying to set a redirect URL that has parameter using .htaccess
The code below works
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} /+news-search\?category=95
RewriteRule ^ http://www.test.net/about/ad/ [R=301,L]
</IfModule>
When I input the following URL:
http://www.kow.work/doctor/news-search?category=95
I get this as a result:
http://www.example.net/about/ad/?/doctor/news-search
The expected result, however, is:
http://www.example.net/about/ad/
You need to remove the query string using the QSD flag. Try:
RewriteRule ^ http://www.test.net/about/ad/ [L,R=301,QSD]
or the old way, adding a ?
RewriteRule ^ http://www.test.net/about/ad/? [L,R=301]

Redirect from several dynamic URLs to a unique URL

My actual and "desired" URL is (and works fine):
www.example.com/flower
The file is
www.example.com/indexmodelo.php?carpeta=flower
But I have the old URL to the same target ruled by "IP" instead "carpeta"
www.example.com/indexmodelo.php?IP=202
And I need that when you put:
www.example.com/indexmodelo.php?carpeta=flower
OR
www.example.com/indexmodelo.php?IP=202
Go to:
www.example.com/flower
In my .htaccess fil I have:
RewriteEngine on
Options -MultiViews
RewriteCond %{THE_REQUEST} \s/indexmodelo\.php\?carpeta=([0-9a-zA-Z_\-&=]+)\s [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^([0-9a-zA-Z_\-&=]+)$ /indexmodelo.php?carpeta=$1 [L]
Thanks for your help folks!

Put a parameter after url suffix

Using htaccess or any other way how can I pass a parameter to end of url suffix
EX: I need all the .html to be html?v=1
I tried the following
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.html?v=1 [R]
But Its not working
Check first that the query string does not already exist:
RewriteEngine On
RewriteCond %{QUERY_STRING} !v=1
RewriteRule ^(.*)\.html$ $1.html?v=1 [R,L]

page not found with two parameter htaccess rewrite

Hello I am cleaning up my urls by using the htaccess file.
I have a parameter called: page and a parameter called: id.
so my original url is:
http://bouwen040.sayhey.nl/index.php?page=leden&id=15
and I would like it to be:
http://bouwen040.sayhey.nl/leden/15
the page that calls only the 'page' parameter works. The other one is giving a page not found error.
this is my rewriterule code:
RewriteEngine On
RewriteRule ^([A-Za-z0-9\-]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9\-]+)/$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9\-]+)/$ index.php?page=$1&id=$2
I also tried this one:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.php$ /index.php?page=$1&id=$2 [L]
I just don't know why one parameter works and two doesn't ?
Replace your code with this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?page=$1&id=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L,QSA]

Resources