This .htaccess file is in my /public_html/ folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
And this .htaccess is inside my /public_html/public/ folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I need to add a rule like the following:
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
I get an issue with it redirecting too many times.
I need to still use the public folder as my root and the front controller inside /public/ but I want to direct all traffic to https.
Can someone help me understand how to go about this?
Do I need to change my rewrite rules pertaining to the /public/ folder?
Add http->https rule in .htaccess of /public_html/public/ folder as this one:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}/$0 [R=301,NE,L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Make sure to test in a new browser or completely clear browser cache.
Related
This url format https://portal.com/pages does not work but this https://portal.com/index.php/pages works.
I want to be able to remove the index.php from the url.
My root .htaccess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
# RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
While public folder .htaccess file is
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
Try following rules htaccess file. Make sure your index.php is present inside public folder. Please make sure to clear browser cache before testing your URLs.
root htaccess rules file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_URI} !^/public [NC]
RewriteRule ^(.*)/?$ public/$1 [L]
</IfModule>
Public folder inside htaccess Rules file:
<IfModule mod_rewrite.c>
RewriteOptions InheritBefore
Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/?$ index.php?url=$1 [QSA,L]
</IfModule>
Fixes done in OP's attempt:
root htaccess Rules file didn't have https apply rule, so have added it.
Made public applying rule for all kind of urls.
Then in public folder rules file added InheritBefore option to make sure root's file is being inherited to public folder's htaccess rules file.
I have got my .htaccess file working for my main domain (www.domain.com):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
However, for my Subdomain www.domain.com/subdomain/ the icon starts as a secure padlock but then goes to unsecure. I am using this in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any ideas on what I should put in the subdomain file?
Figured this out, there was an image using an external URL.
I have a website working on one server. I am changing hosting, so I created a website on another server for testing.
Everything seems to be working, except CSS. It is not loading at all. I have 777 for tmp folder and mod re_write enabled.
I can see all cached files except for CSS.
Please advise and help
This is my .htacess file in www
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my second htaccess inside app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
This is my third htaccess inside webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
and the url is 23.236.49.24
Add this line:
RewriteBase /
under
RewriteEngine On
in the 3 .htaccess files
Create .htaccess file in webroot folder.
And paste this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I'm facing a problem with a cakephp application.
On my server, I have a folder called DIGIPRESSKIT (this folder is used by the domain www.digipresskit-online.com), I placed all the cake's folders into it and when I load the page, there is no CSS, like cake can't access my webroot.
Is there any chance u check my .htaccess ?
I read lots of forums about that, and here is what they tell me to do :
Code: "root/.htaccess" (/DIGIPRESSKIT)
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
Code: "root/app/.htaccess" (/DIGIPRESSKIT/app)
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
Code: "root/app/webroot/.htaccess"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
Assuming you can have many domains on this host, you can try this solution:
.htaccess on servers root (/)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} digipresskit-online.com
RewriteCond %{REQUEST_URI} !^/DIGIPRESSKIT
RewriteRule ^(.*)$ one/$1 [L]
RewriteRule ^$ / [L]
RewriteRule (.*) /$1 [L]
</IfModule>
.htaccess on subfolder (/DIGIPRESSKIT)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
DIGIPRESSKIT/app and DIGIPRESSKIT/app/webroot/ no change
I need a general rule that maps every URL in the /beta subdirectory to the corresponding URL in the root; essentially I need to remove /beta from all URLs.
In case it makes any difference, the URLs are dynamically generated by WordPress.
Currently my .htaccess file is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#END WordPress
Can you tell me where to put the new lines?
Thank you!
Could you try this?
RewriteEngine On
RewriteRule ^beta/(.*)$ http://example.com/$1 [R=301,L]
Your question is not entirely clear, but I would bet that what you want is having a Wordpress installed in somedir/beta appear in yoursite.com/ instead of yoursite.com/beta/. The rules you pasted are in somedir/beta/.htaccess, and are the default Wordpress rules. You must leave those alone.
What you need for that is to put the following rules in the root directory, as in, somedir/.htaccess, after changing example.com to your own domain. Your webserver first reads this root .htaccess, and when it does, it will know to rewrite requests to /beta.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/beta/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /beta/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ beta/index.php [L]
</IfModule>
More info in the Codex:
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory