http://npp.demo.com:8080/mydemo/current.php
above my real URL.
I want below url with hidden query string
http://npp.demo.com:8080/mydemo/try/current.php
I try diffrent type of method but no success.
RewriteRule ^([^/.]+)/try([^/.]*)?$ $2?id=%1&file_name=$2&full_file_path=%2&one=$1&%{QUERY_STRING}
RewriteRule ^([^/.]+)/([^/.]*)?$ $2?id=%1&file_name=$2&full_file_path=%2&one=$1&%{QUERY_STRING}
RewriteCond %{ENV:TEST} ^([^/]+)/$ [OR]
RewriteCond %{REQUEST_URI} ^/([^/]+)/$
RewriteRule ^([^/]+)try/?$ current.php?id=$1&file_name=$2&full_file_path=%2&one=$1 [NC,L,QSA]
RewriteCond %{ENV:TEST} ^([^/]+)/(.+)$ [OR]
RewriteCond %{REQUEST_URI} ^/([^/]+)/(.+)$
RewriteRule ^(.+)/try(.*)/?$ $2?id=%1&file_name=$2&full_file_path=%2&one=$1 [NC,L,QSA]
Related
I am having a following htaccess rule to redirect all the subdomain requests to my web page index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^.*$ index.php?subdomain=%1
Now I want to redirect some of the subdomain requests to someother webpage category.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^jobs\.([^\.]+)\.([^\.]+)/subfolder$ [OR]
RewriteCond %{HTTP_HOST} ^jobs\.([^\.]+)\.([^\.]+)/subfolder/$
RewriteRule ^.*$ category.php?did=%1 [L,QSA]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^.*$ index.php?subdomain=%1
But the code is not redirected to category.php instead it redirects to index.php
Please help me solve this problem
Edited code
RewriteCond %{HTTP_HOST} !^www
#RewriteCond %{HTTP_HOST} ^jobs\.([^\.]+)\.([^\.]+)/subfolder$ [OR]
#RewriteCond %{HTTP_HOST} ^jobs\.([^\.]+)\.([^\.]+)/subfolder/$
RewriteRule ^jobs\.([^\.]+)\.([^\.]+)/subfolder$ category.php?did=jobs [L,QSA]
RewriteRule ^jobs\.([^\.]+)\.([^\.]+)/subfolder/$ category.php?did=jobs [L,QSA]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteCond %{REQUEST_URI} !category.php$
RewriteRule ^.*$ index.php?subdomain=%1
i have a problem with url rewrite, i have to exclude some directory in whitch there are some file as css,image and other. Howewer i have to
RewriteEngine On
RewriteCond %{REQUEST_URI} !configurazione/ [OR]
RewriteCond %{REQUEST_URI} !funzioni/ [OR]
RewriteCond %{REQUEST_URI} !img/ [OR]
RewriteCond %{REQUEST_URI} !imgprodotti/ [OR]
RewriteCond %{REQUEST_URI} !imgslider/ [OR]
RewriteCond %{REQUEST_URI} !js/ [OR]
RewriteCond %{REQUEST_URI} !palma/ [OR]
RewriteCond %{REQUEST_URI} !sezioni/
RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+).html$ index.php?pag=$1&prodotti=$2&prodotto=$3 [L]
RewriteRule ^([a-z]+)/([a-z]+)/ index.php?pag=$1&prodotti=$2 [L]
RewriteRule ^([a-z]+)/ index.php?pag=$1 [L]
RewriteCond is only applicable to very next RewriteRule. Try this code instead with THE_REQUEST:
RewriteCond %{THE_REQUEST} /(funzioni|img|imgprodotti|js|palma|sezioni|configurazione)/
RewriteRule ^ - [L]
RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+).html$ index.php?pag=$1&prodotti=$2&prodotto=$3 [L,QSA]
RewriteRule ^([a-z]+)/([a-z]+)/ index.php?pag=$1&prodotti=$2 [L,QSA]
RewriteRule ^([a-z]+)/ index.php?pag=$1 [L,QSA]
I'm having trouble getting this to work:
This is the original URL pattern:
/supportcp/index.html
/supportcp/content/edit.html
/supportcp/members/user_banning.html
/supportcp/*
All should redirect to /support
I started with the following .htaccess code but unfortunately I end up with the wrong URL.
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} !page=supportcp
RewriteRule ^index.php /support/ [R,L]
Result: /support/?/support/ (wrong)
Help is greatly appreciated!
You need to append ? in the target URI to strip off any query string:
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} !page=supportcp
RewriteRule ^index\.php$ /support/? [R,NC,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
I want to rewrite the URL like below:
URL: http://localhost/my_site/?file_name=sample
This is my URL I want to show it like:
URL: http://localhost/my_site/sample
that means I want to remove file_name parameter and get the parameter value and set it in URL, for setting this I have used below code:
RewriteEngine On
RewriteBase /my_site/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /?file_name=$1 [QSA,L]
But its not working, when I type http://localhost/my_site/sample its showing me the list of all sites present in my local that means its taking me to http://localhost instead of require page. What wrong I am doing?
Please help, Thanks in advance
Assuming that mysite folder is under DocumentRoot. add this to your
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !\.\w+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) /$1/ [R,L]
RewriteCond %{REQUEST_URI} ^/(my_site)/([\w\d-]+)/$ [NC]
RewriteRule ^ %1/?file_name=%2 [L,QSA]
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} (?:(.*)&)?file_name=([\w\d-]+)(.*) [NC]
RewriteRule ^(my_site) $1/%2/?%1%3 [L,R]
For server side:
RewriteCond %{REQUEST_URI} ^/([\w\d-]+)/$ [NC]
RewriteRule ^ /?file_name=%1 [L,QSA]
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} (?:(.*)&)?file_name=([\w\d-]+)(.*) [NC]
RewriteRule ^ %2/?%1%3 [L,R]
try this, if it works:
RewriteEngine On
RewriteBase /my_site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ file_name=/$1 [L]
caution: untested
I have a site I've written in php.
The addresses are as follows:
http://www.site.com/page.php
I'd like any request to:
www.site.com/page.php
or
www.site.com/page
To go to:
www.site.com/page/
(And force a www.)
Can anyone help me?
For domain :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
For your first directory :
RewriteRule ^/([^/]*)(\.php)? /$1/
RewriteRule ^page.php$ http://www.site.com/page/ [QSA,L]
RewriteRule ^page$ http://www.site.com/page/ [QSA,L]
Maybe this will work.
This should do what you wanted:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?)\.php [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?[^/\s])\s [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST}/%1 ^(www\.)?(.*?)/?$
RewriteRule ^ http://www.%2/ [R=301,L]
# Assuming you want to write the request back to page.php too...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ $1.php
Tim's answer is the closest, but it also does adds the trailing slash to images and css...
So taking Tim's answer, and slightly editing it gives us:
RewriteEngine on
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?)\.php [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?[^/\s])\s [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST}/%1 ^(www\.)?(.*?)/?$
RewriteRule ^ http://www.%2/ [R=301,L]
# Assuming you want to write the request back to page.php too...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ $1.php
Which should work!