I'm currently using this rewrite rule
RewriteRule ^([\w-]+)/?$ ../new/index.php?product=$1
which is located in the folder /old to make this
sample.com/old/123
forward to this
sample.com/new/index.php?product=123
I'd like to include another variable in this rule to make this
sample.com/old/123?type=1
forward to this:
sample.com/new/index.php?product=123&type=1
Can someone help me figure this put please?
If you add [QSA] to the end of your RewriteRule, it should pass through any additional query strings to the new URL:
RewriteRule ^([\w-]+)/?$ ../new/index.php?product=$1 [QSA]
Related
I have searched but cannot find a specific answer for this exact redirect style...
I have this structure of URL with this specific parameter:
https://websitename.com/directory/index.php?option=com_virtuemart&view=cart
I want it redirected to:
https://websitename.com/shopping-cart/
Note that the above mentioned "directory" changes, but the index.php with the parameters stay the same. No matter what the directory is, I always want it to go to the same exact redirect.
I cannot seem to get the right redirect working in htaccess. Can anyone help?
You can use this redirect rule as your first rule in site root .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} /(?:index\.php)?\?option=com_virtuemart&view=cart [NC]
RewriteRule ^ /shopping-cart/? [L,R=308]
# remaining rules go below this
You can use a set like this. It takes care on the param view=cart
RewriteCond %{QUERY_STRING} (^|&)view=cart
RewriteRule ^(.*)$ /shopping-cart/? [L,NC,R=301]
If you want to keep the querystring params, then change
/shopping-cart/?
to
/shopping-cart/
without questionmark
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]
i want to redirect all of requests to a address that contains a regular expreession.
example
i.png to ../../templates/default-(something)/i.png
this is my Rewite Rule, but it not work.
RewriteRule ^(.*) ../../templates/default-(.*)/image/$1
thank you.
Again, not really sure what you're trying to do, but perhaps it's a folder?
If your structure was http://......./xxxx/something/i.png
RewriteRule ^.*?/(.*?)/(.*?\.png)$ ../../templates/default-$1/image/$2
Would get you http://..../templates/default-something/image/i.png\
OR if you just want to redirect it to something you define:
RewriteRule ^(.*)$ ../../templates/default-something/image/$1
hi i am trying to make clean and neat url using rewrite rule
I want to achive :
abc.com/t/param1/param2
Rewite rule that I wrote
RewriteRule ^t/(.+)/(.+)$ t/index.php?v=$1&t=$2 [L]
but it doen't work it redirects to :
http://abc.com/?v=param1&t=param2
Your regex should only match characters that aren't slashes. So your rule should look like
RewriteRule ^t/[^/]+/[^/]+$ t/index.php?v=$1&t=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/$ /?v=$1&t=$2 [L]
I have a url like this.
/domains/details.php (NOTE: domains is dynamic and can be anything)
How do I remove the domains part from the URL using .htaccess so the actual lookup is:
/details.php
OR it'll be cool if I can get domains into the URL.
/details.php?page=domains
Thanks!
Scott
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/details.php$ /details.php?page=$1 [R=301]
Leave off the [R=301] if you want an internal redirect rather than an actual HTTP redirect.
To preserve existing query parameters you can change the rule to this:
RewriteRule ^([^/]+)/details.php(.*)$ /details.php?page=$1&%{QUERY_STRING} [R=301]
Please try to use the following rules to deal with your last request:
RewriteRule ^(?!domains/.*)([^/]+)/details.php$ domains/details.php?page=$1 [R=301,QSA]
RewriteRule ^domains/details.php$ details.php [NC,L]