I have page http://mysite.ru/test/abc.html and I would like that it will be accessable by url http://mysite.ru/?param=abc.html
I tried to use rewrite rule:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?param=(.*)$ /test/$1
but it doesn't work. Please help what is wrong?
Try this:
RewriteCond %{QUERY_STRING} ^param=(.*)$ [NC]
RewriteRule ^$ /test/%1? [L,R]
Related
I have a page like:
page.php?mode=dashboard&hl=en
and i want to use like:
site.com/dashboard?hl=en
how must i use RewriteRule? Thanks...
EDIT: I think this is not possible with .htaccess. Need to use javascript.
wish it helps you
# Redirect /Category.php?Category_Id=10&Category_Title=some-text
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^Category_Id=(\d+)&Category_Title=([\w-]+)$
RewriteRule ^Category\.php$ /Category/%1/%2? [R=301,L]
You may be able to use this code in site root .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} /page\.php\?mode=([^\s&]+)&(hl=[^\s&]+) [NC]
RewriteRule ^ /%1?%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w-]+)/?$ page.php?mode=$1 [L,QSA]
I want to redirect the url of http://sitename/modules/fb/fb.php to http://sitename/modules/take_control .How can i do that using htaccess
I tried like
RewriteRule ^/?modules/fb/fb\.php$ take_control , Is that right ?
Your solution is the opposite of what you most likely want if you are trying to rewrite to take_control.
Give this a try. These rules should provide the rewrite with take_control as the URI both ways.
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /+modules/fb/fb\.php [NC]
RewriteRule ^ /take_control/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^take_control/?$ /modules/fb/fb.php [L]
I would like to redirect http://example.com/video.php?id=123A_BC to http://example.com/video/123A_BC in .htaccess file by using mod_rewrite.
You need to use rewrite instead of redirecting for clean url.
Please try this,
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)$ $1.php?id=$2 [QSA,NC,L]
The following code solved my problem
RewriteCond %{REQUEST_URI} ^/video\.php$
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^(.*) video/%1? [R=301,L]
I use this redirect because my website is inside a subfolder (www.domain.com/subfolder/)
So if someone enters the website, it will load like this: http://domain.com
What do I need to add or change in .htaccess so that it redirects automatically to https://domain.com, counting that the website is at domain.com/subfolder
I have tried various redirect codes, but no success. If someone is kind to point me in the right direction or give me a hint.
Thanks for the help.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder/index.html [L]
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule !^subfolder/ subfolder%{REQUEST_URI} [L,NC]
I'm having an issue with a query string, although I'm not sure what i'm tryign to do is possible.
I have the following url with a search query attached:
subdomain.mysite.com/search/?search=searchquery
but I need it to redirect to the following url including the query string:
subdomain.mysite.com/search/?rs=searchquery
I was wondering if this is possible with a mod_rewrite?
I've tried the following:
RewriteCond %{REQUEST_URI} ^/search/?$
RewriteCond %{QUERY_STRING} ^search=([0-9]*)$
RewriteRule ^(.*)$ http://subdomain.mysite.com/search/?rs=% [L,R=301]
I don't know if my Syntax is incorrect or i'm just barking up the wrong tree. Any help would be awesome.
This is the Start of my HTAccess File - This is a Wordpress site with the rewrite rule provided by user: Amine Hajyoussef:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} ^/search/?$
RewriteCond %{QUERY_STRING} ^search=([^&]*)$
RewriteRule ^(.*)$ /search/?rs=%1 [L,R=301]
</IfModule>
Unfortunately this doesnt appear to work? Any ideas?
you forgot the 1 after %, i have also changed the search string so it can be anything instead of just number.
RewriteCond %{REQUEST_URI} ^/search/?$
RewriteCond %{QUERY_STRING} ^search=([^&]*)$
RewriteRule ^(.*)$ /search/?rs=%1 [L,R=301]