I am trying to rewrite rule in htaccess for subfolders created dynamically /folder/folder/folder/folder/index.php?product=car
i want like this folder/folder/folder/folder/product/car
code
RewriteCond %{QUERY_STRING} ^product=1$
RewriteRule ^([^/]+)/? index.php?product=$1 [L]
If I understand you correctly
RewriteEngine On
RewriteRule ^((?:[^/]+?/)*)product/(.+)$ $1index.php?product=$2 [L,NC]
Related
Can you please show me how to create rewrite rule in htaccess to convert from default.asp to index.php with the same directory?
Here is what I have so far
RewriteRule ^(.*)\.asp$ ^(.*)\index.php$ [R,L,NC]
But it is not working. I like to be able to convert from defaut.asp to index.php regardless of the URL structure.
For example, if https://myownsite.com/about/that/default.asp then it will become https://myownsite.com/about/that/index.php
Thank you
You can use this :
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(.*?)default\.asp$
RewriteRule ^ /%1index.php [R=301,L]
I am new at this. How can I rewrite this in .htaccess correctly?
My visitor access:
http://www.example.com/old/xxx/?id=1
But actually source is from:
http://www.example.com/new/(same name with xxx)/1.html
You can try this
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteCond %{REQUEST_URI} ^/old/xxx/?id=%1\.html$
RewriteRule ^(.*)$ http://www.siteurl.org/new/xxx/?id=%1\.html [L,R=301]
I have this dynamically generated url: /folder/folder/folder/folder/index.php?product=bike
Which i need to convert to a static url: /folder/folder/folder/folder/product/bike
.htaccess is in the root folder
code
RewriteCond %{QUERY_STRING} ^product=1$
RewriteRule ^([^/]+)/? index.php?product=$1 [L]
Assuming you need ../index.php?product=bike to be rewritten as ../product/bike/
RewriteCond %{QUERY_STRING} (^|&)product=(.*)(&|$)
RewriteRule ^(.*)/index.php$ $1/product/%1? [NC,L]
I want to rewrite two virtual subfolders /content/view/, and /content/section/. I now have this:
RewriteCond %{REQUEST_URI} ^htaccesstst/content/(view|section)+
RewriteRule ^$ http://www\.google\.nl [L,R=301]
This rewrites /content, /content/, /content/view/, /content/section/, which is correct. BUT it rewrites /content/ (with nothing after it) too. I don't want this! Help?
You can replace it with:
RewriteRule ^htaccesstst/content/(view|section)/?$ http://www.google.nl [L,R=301]
I have an HTML file I want rewritten as a subfolder on the server.
http://www.example.com/kids-and-family/185-summer-camp.html
to be shortened to:
http://www.example.com/camp
Is there an rewrite condition where I can make this happen in .htaccess?
Can I say if (/camp) then display /kids-and-family/185-summer-camp.html?
I have been looking for this but have not found anything.
Try this rule:
RewriteEngine on
RewriteRule ^camp$ kids-and-family/185-summer-camp.html [L]
If you want an external redirect, add the R flag ([L,R]) with an additional redirect status like 301 for a permanent redirect ([L,R=301]).
in your .htaccess file, try this:
RewriteEngine on
RewriteCond %{REQUEST_URI} "/camp"
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{DOCUMENT_ROOT} /kids-and-family/185-summer-camp.html -s
RewriteRule ^$ /kids-and-family/185-summer-camp.html [L]