my directory:
domain.com/
-----------subdomain/
---------------------subdirectory/
I've created subdomain as subdomain.domain.com
I need to access subdomain.domain.com/subdirectory but is shows: 404
I can access domain.com/subdomain/subdirectory/
please tell me how to do that.
### EDITED ###########
My .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA]
RewriteRule ^([0-9]+^)$ download/content/$1 [L]
<IfModule mod_php5.c>
php_value upload_max_filesize 200M
php_value post_max_size 200M
</IfModule>
if I add the following before my rule, it stops my existing. and if I add it after my rule. it doesn't execute because of [L] flag
RewriteCond %{HTTP_HOST} ^wap\.
RewriteRule !^wap/ wap%{REQUEST_URI} [L]
Have this rule in your root htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^wap\.
RewriteRule !^wap/ wap%{REQUEST_URI} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^([0-9]+)$ download/content/$1 [L]
<IfModule mod_php5.c>
php_value upload_max_filesize 200M
php_value post_max_size 200M
</IfModule>
Related
I'm currently trying to make a htaccess thing to find the file in new/ if the request uri not contains api or list. I tried to do a thing like this but, it shows 403 error. Are there a easier way to filter, or?
RewriteEngine on
RewriteCond %{REQUEST_URI} /api/ [NC]
RewriteCond %{REQUEST_URI} /list/ [NC]
RewriteRule ^/(.*)$/ new/$1 [L, R]
Full htaccess code
#remove html file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
#remove php file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
#set max post size
php_value memory_limit 2048M
php_value max_execution_time 3000
php_value max_input_time 6000
php_value post_max_size 800M
php_value upload_max_filesize 200M
#Caching schema
<FilesMatch "\.(png|svg|css|eot|ttf|woff|woff2|otf|js|css)$">
Header set Cache-Control "public, max-age=86400000"
</FilesMatch>
DirectoryIndex index.html
#Custom 404 errors
ErrorDocument 404 /404.html
#Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files error_log>
order allow,deny
deny from all
</Files>
#Prevent directory listings
Options All -Indexes
EDIT: With OP's full htaccess file please try following.
#remove html file extension
RewriteEngine on
##For external redirect rule.
RewriteCond %{THE_REQUEST} !\s/(?:api|list).*\s [NC]
RewriteRule ^(.*)/?$ new/$1 [L,R=301]
##For internal redirect rule.
RewriteRule ^new/(.*)/?$ $1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)/?$ $1.html [NC,L]
#remove php file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/?$ $1.php [QSA,NC,L]
#set max post size
php_value memory_limit 2048M
php_value max_execution_time 3000
php_value max_input_time 6000
php_value post_max_size 800M
php_value upload_max_filesize 200M
#Caching schema
<FilesMatch "\.(png|svg|css|eot|ttf|woff|woff2|otf|js|css)$">
Header set Cache-Control "public, max-age=86400000"
</FilesMatch>
DirectoryIndex index.html
#Custom 404 errors
ErrorDocument 404 /404.html
#Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files error_log>
order allow,deny
deny from all
</Files>
#Prevent directory listings
Options All -Indexes
With your shown attempts/rules, could you please try following once. Please make sure to clear browser cache before testing your URLs.
RewriteEngine on
##For external redirect rule.
RewriteCond %{REQUEST_URI} !^/(?:api|list)/? [NC]
RewriteRule ^(.*)/?$ new/$1 [L,R=301]
##For internal redirect rule.
RewriteRule ^new/(.*)/?$ $1 [L,NC]
OR try following rules set: Please make sure try only 1 set at a time, either above OR following.
RewriteEngine on
##For external redirect rule.
RewriteCond %{THE_REQUEST} !\s/(?:api|list).*\s [NC]
RewriteRule ^(.*)/?$ new/$1 [L,R=301]
##For internal redirect rule.
RewriteRule ^new/(.*)/?$ $1 [L,NC]
You may try these rules in your site root .htaccess:
RewriteEngine On
# redirect to /new if not /api, /list, /new and file exists in /new
RewriteCond %{THE_REQUEST} !\s/+(new|api|list)/ [NC]
RewriteCond %{DOCUMENT_ROOT}/new/$0 -f
RewriteRule .* /new/$0 [L,R=301,NE]
## remaining rules go below this line ##
# remove html file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
# remove php file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
Make sure to test it after clearing your browser cache or test from a new browser.
I try actually to change my url => www.mysite.com to www.mysite.com/fr/ and i have to use my .htaccess for that.
So i changed my .htaccess from my root like that:
SetEnv SHORT_OPEN_TAGS 0
SetEnv REGISTER_GLOBALS 0
SetEnv MAGIC_QUOTES 0
SetEnv SESSION_AUTOSTART 0
SetEnv ZEND_OPTIMIZER 1
SetEnv PHP_VER 5_3
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
RedirectPermanent / http://www.chat.com/fr/
</IfModule>
and i have my /web/.htaccess like that:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
and when i try to upload my site, i have this url : www.mysite.com/fr/fr/fr/fr/... and an error. Someone can help me ? :(
Your rules will indeed cause a redirect loop. Try this in root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?$ /fr/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
Make sure to test this after clearing your browser cache.
So right now my site looks like this:
https://www.example.com
It has many languages:
https://www.example.com/es
https://www.example.com/hk
(etc...)
How do I modify the following .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
php_value upload_max_filesize 110M
php_value post_max_size 110M
so that only paegs with /cn/ preceding them are insecure? (http instead of https) Example:
http://www.example.com/cn/
http://www.example.com/cn/subpage/
You can use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# http requests anything other than /cn should become https
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/cn(/.*)?\s [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L,NE]
# https requests for /cn should become http
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /cn(/.*)?\s [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
php_value upload_max_filesize 110M
php_value post_max_size 110M
I'm using the following .htaccess so that pages preceded by /cn/ load with http (the rest loads with https:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# http requests anything other than /cn should become https
RewriteCond %{HTTPS} off
RewriteRule !^cn(/.*)?$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L,NE]
# https requests for /cn should become http
RewriteCond %{HTTPS} on
RewriteRule ^cn(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
php_value upload_max_filesize 110M
php_value post_max_size 110M
The strange thing is that the page just keeps loading forever. What could be causing this?
I have .htaccess like this:
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
but I want to skip these rules if url contains e.g. admin, administration words just after domain name (eg. domain.com/admin/ or domain.com/administration/)
Add the following conditions before your rules:
RewriteCond %{REQUEST_URI} !^/admin/
RewriteCond %{REQUEST_URI} !^/administration/