i wish to add more url variables to my url... whatever there is after ? i wish to retrieve it as a urls variable Thank YOU!
RewriteRule ^(.*).html?(.*)$ products.cfm?categ=$1&urls=$2 [NC,L]
RewriteRule ^products.cfm?categ=(.*)&urls=(.*)$ (.*).html?(.*) [NC,R=301,L]
RewriteCond %{QUERY_STRING} ^condition=(\d+)&maxprice=(\d+)&minprice=(\d+)&persons=(\d+)&maxyear=(\d+)&minyear=(\d+)&order=(\d+)$ [NC]
RewriteRule ^category/(.*).html$ products.cfm?categ=$1&condition=%1&maxprice=%2&minprice=%3&persons=%4&maxyear=%5&minyear=%6&order=%7? [NC,L]
Related
I need a rule that rewrites
http://example.com/page.html?page=2
to
http://example.com/page.html/page/2
I already tried this rule:
RewriteRule ^(.*)page=(.*)$ http://example.com/$1/page/$2/
but this does not work! :( Where I'm wrong?
You can try this one:
RewriteCond %{QUERY_STRING} page=(\d+) [NC]
RewriteRule (.*) /$1/page/%1/? [R=301,L]
It should works.
I am using
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule ^wp-admin/admin-ajax.php(.*)$ dl-file.php?file=$1 [QSA,L]
to protect worpdress files which are called with admin-ajax.php from not logged in users. But this breaks ajax for all visitors - so some things won't work for non registered users.
How could I instead just specify a rewriterule for a specific url, for instance this one:
RewriteRule ^wp-admin/admin-ajax.php?action=ajax_request&fn=download&id=(.*) [QSA,L]
id would be a number for a file.
is there a way to do this with htaccess?
I followed user hakre https://wordpress.stackexchange.com/questions/37144/how-to-protect-uploads-if-user-is-not-logged-in using dl-file.php
Thank you!
AD
You can add another RewriteCond based on %{QUERY_STRING} variable to target a specific URL:
RewriteCond %{QUERY_STRING} (?:^|&)action=ajax_request&fn=download&id= [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule ^wp-admin/admin-ajax\.php$ dl-file.php?file=$1 [QSA,L]
I am trying to redirect all requests coming in to the web server as http://portal.company.com/legacy to http://portal.company.com/wps/portal/public/legacy/legacyportlet with the following rule, but it is not working as expected.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^portal\.company\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/legacy$ [NC]
RewriteRule ^(.*)$ /wps/portal/public/legacy/legacyportlet$1 [NC,L,PT]
I have also tried
RewriteCond %{HTTP_HOST} ^portal\.company\.com$ [NC]
RewriteRule ^/legacy /wps/portal/public/legacy/legacyportlet [NC,L,PT]
Any help would be greatly appreciated!
Thanks
It doesn't look like your source or target URLs change in any way, so possibly you're better off using Apache's basic Redirect directive which just redirects one URL to another.
Use this rule:
RewriteCond %{HTTP_HOST} ^portal\.company\.com$ [NC]
RewriteRule ^legacy/?$ /wps/portal/public/legacy/legacyportlet [NC,L]
Remember that in .htaccess RewriteRule doesn't match leading slash of URI.
I have the following rewrite rule in place:
RewriteRule ^register/?$ /fitch/index.php?cmd=register [NC,L,QSA]
Requests to mysite.com/register are rewritten to
mysite.com/fitch/index.php?cmd=register
I want to allow an optional parameter to be passed as well, such that requests to
mysite.com/register/sender=models directs me to
mysite.com/fitch/index.php?cmd=register&sender=models
Perhaps:
RewriteRule ^register/(.*) /fitch/index.php?cmd=register&$1
For any number of paths -> query string params:
RewriteCond %{REQUEST_URI} ^/register/
RewriteRule ^(.*)/(.*)$ /$1&$2 [L]
RewriteCond %{REQUEST_URI} ^/register&
RewriteRule ^(.*)$ /fitch/index.php?cmd=$1 [L,QSA]
This will rewrite URL's like:
http://mysite.com/register/a=b/1=2/c=d
to:
http://mysite.com/fitch/index.php?cmd=register&a=b&1=2&c=d
apache .htaccess
RewriteRule ^promotion\.php\?do=content&id=38&mail$ promotion\.php?lang=tc&do=content&id=38 [R,L]
Thank you.
To match the query string, you have to use %{QUERY_STRING} like shown below.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^do=content&id=38&mail$ [NC]
RewriteRule ^promotion\.php$ promotion.php?lang=tc&do=content&id=38 [R,L]
Put it in the folder where promotion.php is present. I'm not sure how to involve RewriteCond ${HTTP_HOST} above.