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]
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]
I have one question and I dont find the solution.
I habe a subfolder in my web root an I want to redirect all URLs to this subfolder without changing the URL.
Ex: domain.com/article123.html ->redirecting-> domain.com/subfolder/article123.html but in addressbar stays domain.com/artcle123.com
so I put the following in my root htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule !^subfolder/ /subfolder%{REQUEST_URI} [L,NC]
But now when I test an URL with http://httpstatus.io I get the following
301 → Error while fetching URL. 11 redirect
in subfolder i have another htaccess:
RewriteCond %{REQUEST_METHOD} =GET
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} "(.*)index.php"
RewriteRule ^index\.php$ %1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.(php|css|js|gif|jpg|jpeg|png)$ [NC]
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_URI} (.*)?/admin/(.*)
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_URI} (.*)?/images/(.*)
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_URI} (.*)?/templates/(.*)
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^(.+) - [L]
##boosted CONTENT
RewriteRule (^[a-z]{2})/(.*/)?info/([A-Za-z0-9_-]+)\.html.* shop_content.php?language=$1&gm_boosted_content=$3&%{QUERY_STRING} [PT,L]
RewriteRule (.*/)?info/([A-Za-z0-9_-]+)\.html.* shop_content.php?gm_boosted_content=$2&%{QUERY_STRING} [PT,L]
##boosted PRODUCTS
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)\.html product_info.php?language=$1&gm_boosted_product=$3&%{QUERY_STRING} [PT,L]
RewriteRule (.*/)?([A-Za-z0-9_-]+)\.html product_info.php?gm_boosted_product=$2&%{QUERY_STRING} [PT,L]
##boosted CATEGORIES
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)/?.* index.php?language=$1&gm_boosted_category=$3&%{QUERY_STRING} [L]
RewriteRule (.*/)?([A-Za-z0-9_-]+)/?.* index.php?gm_boosted_category=$2&%{QUERY_STRING} [L]
I dont know why. Can anyone help?
root .htaccess looks fine, try this in subfolder/.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} =GET
RewriteCond %{THE_REQUEST} /index\.php
RewriteCond %{REQUEST_URI} (.*)index\.php
RewriteRule ^index\.php$ %1 [R=301,L,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.(php|css|js|gif|jpg|jpeg|png)$ [NC,OR]
RewriteCond %{REQUEST_URI} /(admin|images|templates)/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
##boosted CONTENT
RewriteRule (^[a-z]{2})/(.*/)?info/([\w-]+)\.html shop_content.php?language=$1&gm_boosted_content=$3 [QSA,L,NC]
RewriteRule (.*/)?info/([\w-]+)\.html shop_content.php?gm_boosted_content=$2 [QSA,L,NC]
##boosted PRODUCTS
RewriteRule (^[a-z]{2})/(.*/)?([\w-]+)\.html product_info.php?language=$1&gm_boosted_product=$3 [QSA,L,NC]
RewriteRule (.*/)?([\w-]+)\.html product_info.php?gm_boosted_product=$2 [QSA,NC,L]
##boosted CATEGORIES
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)/? index.php?language=$1&gm_boosted_category=$3 [L,QSA,NC]
RewriteRule (.*/)?([\w-]+)/? index.php?gm_boosted_category=$2 [L,QSA,NC]
hello all i have a url like
http://www.domain.com/dash?do=about&w=me
but i would like to make it like
http://www.domain.com/dash/about/me
i have these things in my htaccess file.
RewriteEngine On
RewriteBase /
Options All -Indexes
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^ - [L]
ErrorDocument 403 /www.domain.com/error404.php
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.*$ [NC]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# redirect /profile?eid=1 to /eid/1
RewriteCond %{THE_REQUEST} \s/+profile(?:\.php)?\?(eid)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /eid/1 to /profile.php?eid=1
RewriteRule ^(eid)/(\d+)$ profile.php?$1=$2 [L,QSA,NC]
# redirect /dept?did=1 to /did/1
RewriteCond %{THE_REQUEST} \s/+dept(?:\.php)?\?(did)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /did/1 to /dept.php?did=1
RewriteRule ^(did)/(\d+)$ dept.php?$1=$2 [L,QSA,NC]
# redirect /job-details?job=1 to /job/1
RewriteCond %{THE_REQUEST} \s/+job-details(?:\.php)?\?(job)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /job/1 to /job-details.php?job=1
RewriteRule ^(job)/(\d+)$ job-details.php?$1=$2 [L,QSA,NC]
RewriteCond %{THE_REQUEST} \s/+enterprise\.php\?url=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ enterprise.php?url=$1 [L,QSA]
can any one suggest something to achieve this i have ?do=about&w=me comon everywhere and just need to do it like /about/me after the page.
It is slowly becoming difficult to maintain due to so many rules but here it is:
ErrorDocument 403 /www.domain.com/error404.php
Options All -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^ - [L]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.*$ [NC]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# redirect /profile?eid=1 to /eid/1
RewriteCond %{THE_REQUEST} \s/+profile(?:\.php)?\?(eid)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /eid/1 to /profile.php?eid=1
RewriteRule ^(eid)/(\d+)$ profile.php?$1=$2 [L,QSA,NC]
# redirect /dept?did=1 to /did/1
RewriteCond %{THE_REQUEST} \s/+dept(?:\.php)?\?(did)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /did/1 to /dept.php?did=1
RewriteRule ^(did)/(\d+)$ dept.php?$1=$2 [L,QSA,NC]
# redirect /job-details?job=1 to /job/1
RewriteCond %{THE_REQUEST} \s/+job-details(?:\.php)?\?(job)=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
# internally rewrite /job/1 to /job-details.php?job=1
RewriteRule ^(job)/(\d+)$ job-details.php?$1=$2 [L,QSA,NC]
RewriteCond %{THE_REQUEST} \s/+enterprise\.php\?url=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=302,L,NE]
# /dash?do=about&w=me => /dash/about/me
RewriteCond %{THE_REQUEST} \s/+([^?]+)(?:.php)?\?do=([^&\s]+)&w=([^&\s]+)\s [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ $1.php?do=$2&w=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ enterprise.php?url=$1 [L,QSA]
RewriteEngine On
RewriteBase /cpmsystem/
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]
RewriteCond %{HTTP_HOST} !^\. [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} system|application
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
#
my .htaccess is not working, can anyone please tell me what is wrong with my codes?
#
I'm trying to redirect any non-existing URL back to its main page.
Below is my .htaccess code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]
Add that:
RewriteRule ^([^.]+\.[^/.]{3,4})/.* $1 [R=301,L]
And no need to use more than one RewriteEngine on for all the .htaccess.