I have a problem with my htacess file.
I have a php mvc system set up with the root looking like public [folder] application [folder] htaccess
The first htaccess reads
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
This is to remove public from the url i assume ?
The second htaccess file i have is in the public directory with the index.php file which starts the php app
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/public) /$1 [L]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
This has been written to force the url to go to https rather than http, The problem im having is if the url is typed into the url bar as http://example.com and the rewrite happens it will take me to https://example.com/public , I am trying to remove the public directory from the url if this happens, Any help would be much apreciated.
Cheers Ryan
Rewrites doesn't remove parts or change the URL in the users browser.
The first htaccess simply makes all requests to /
load files from the /public
-folder internally, without the user noticing.
If you don't want /public
to be available, you should change the document root to point to the public folder instead of the folder above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.