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]
Related
i wanted to change the url for my subdirectory from "subdomain1.main.com/subdirectory" to "subdomain2.subdomain1.domain.com"
i tried the htaccess code below but it doesnt work. can someone please help?
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain1\.domain\.com$ [NC]
RewriteRule ^subdirectory/(.*)$ http://subdomain2.subdomain1.domain.com/$1 [L,NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain2.\subdomain1\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !(jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule !subdirectory%{REQUEST_URI} [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Try this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain1\.domain\.com$
RewriteRule ^subdirectory/(.*)$ http://subdomain2.subdomain1.domain.com/$1 [L,QSA,R=301]
RewriteCond %{HTTP_HOST} ^subdomain2\.subdomain1\.domain\.com$
RewriteCond %{REQUEST_URI} !^subdirectory/
RewriteRule ^(.*)$ /subdirectory/$1 [L,QSA]
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]
I'm trying to add a trailing slash to the url. It nearly works but there is a little problem i don't understand.
When i call the site http://domain.com/test > rewrite to www.domain.com > the trailing slash is added.
When i call the site directly http://www.domain.com/test > nothing is added.
Important to me is that https:// has to be redirected to https:// an not to http://
Here's my config:
############################################
enable rewrites
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !.html
RewriteCond %{REQUEST_URI} !.php
RewriteCond %{QUERY_STRING} !price
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
Replace your rules with these simplified rules:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS}s on(s)|
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.+?)/?$ http%1://www.domain.com/$1/ [R=302,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
I have website http://paweljanicki.pl/Realizacje/.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^paweljanicki.pl$ [NC]
RewriteRule ^(.*)$ http://paweljanicki.pl/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://paweljanicki.pl/$1/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Realizacje.aspx$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Realizacje/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Kontakt.aspx$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Kontakt/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Galeria.aspx$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Galeria/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Linki.aspx$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Linki/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Mapa-strony.aspx$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Mapa-strony/ [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Galeria.aspx$
RewriteCond %{QUERY_STRING} ^gId=([0-9]*)$
RewriteRule ^(.*)$ /Galeria/%1/? [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Galeria.aspx$
RewriteCond %{QUERY_STRING} ^gId=([0-9]*)&sgId=([0-9]*)$
RewriteRule ^(.*)$ /Galeria/%1/%2/? [L,R=301]
RewriteCond %{REQUEST_URI} ^\/Galeria.aspx$
RewriteCond %{QUERY_STRING} ^gId=([0-9]*)&sgId=([0-9]*)&pId=([0-9]*)$
RewriteRule ^(.*)$ /Galeria/%1/%2/%3/? [L,R=301]
RewriteRule ^Galeria/$ Galeria.aspx [L]
RewriteRule ^Galeria/([^/]+)/?$ Galeria.aspx?gId=$1 [L]
RewriteRule ^Galeria/([^/]+)/([^/]+)/?$ Galeria.aspx?gId=$1&sgId=$2 [L]
RewriteRule ^Galeria/([^/]+)/([^/]+)/([^/]+)/?$ Galeria.aspx?gId=$1&sgId=$2&pId=$3 [L]
RewriteCond %{REQUEST_URI} ^\/Realizacje.aspx$
RewriteCond %{QUERY_STRING} ^gId=([0-9]*)$
RewriteRule ^(.*)$ /Realizacje/%1/? [L,R=301]
RewriteRule ^Realizacje/$ Realizacje.aspx [L]
RewriteRule ^Realizacje/([^/]+)/?$ Realizacje.aspx?pId=$1 [L]
RewriteRule ^Kontakt/$ Kontakt.aspx [L]
RewriteRule ^Linki/$ Linki.aspx [L]
RewriteRule ^Mapa-strony/$ Mapa-strony.aspx [L]
RewriteCond %{REQUEST_URI} ^\/Programy-na-Zlecenie/$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /Pisanie-Programow-na-Zamowienie/ [L,R=301]
#to use relative paths in RewriteMap, map files must reside in the same folder as .htaccess
#http://www.helicontech.com/ape/doc/mod_rewrite.htm
RewriteMap mapfile txt:mapfile.txt [NC]
RewriteMap revmapfile txt_rev:mapfile.txt [NC]
#RewriteCond %{QUERY_STRING} (.+)
#RewriteRule ^Default\.aspx$ ${mapfile:%1}? [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ Default.aspx?${revmapfile:$1} [NC,L,NS]
I have htaccess like below, it includes admin also but I don't want htaccess to effect my admin area, so what changes should I do in below code?
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/%1/? [L,R]
Previous conversation: Redirection through htaccess not working
Thanks in advance.
Add the first line.
RewriteCond %{REQUEST_URI} !/admin
RewriteCond %{REQUEST_URI} ^/(my_site)/([\w\d-]+)/$ [NC]
RewriteRule ^ %1/?file_name=%2 [L,QSA]