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.
Related
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.
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 tried all solutions I found about removing index.php from the URL, but I still cannot make it work properly.
Problem:
the URL http://localhost/rc/index.php/person/find shows the correct page.
the URL http://localhost/rc/person/find shows the WAMP main page (without any image) like it redirects to the root's parent folder.
my configuration:
I created .htaccess is placed in my root directory (/www/rc/.htaccess) which contains the following code:
<IfModule mod_rewrite.c>
# Turn on MOD REWRITE engine
RewriteEngine On
#Remove index.php from the URL
RewriteBase /rc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#Also tried the following lines without success
#RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# If mod_rewrite is not installed, fire 404 error
ErrorDocument 404 /index.php
</IfModule>
I have also set $config['index_page'] = ''; (in www/rc/application/config/config.php file).
You must put your rule before CodeIgniter's main rule.
Replace your current code by this one (your htaccess has to be in rc folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rc/
RewriteCond %{THE_REQUEST} \s/rc/index\.php/([^\s]+) [NC]
RewriteRule . %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
The answer was given by Justin Iurman in the comment of the first answer:
Are you sure mod_rewrite is enabled ? You can check it in your apache config
This can be enabled in httpd.conf file or from the WAMP tray icon.
in .htaccess I would like to chop off anything after the 2nd '/'… so http://www.domain.com/parent/child/otherchild would be redirected to http://www.domain.com/parent/
Add these rules to the htaccess file in your document root:
RewriteEngine On
RewriteRule ^([^/]+)/.+$ /$1/ [L,R=301]
Not sure what you meant by pasting all that unreadable code in the comments, but you want to add exclusion conditions like I mentioned in my comments:
AddType application/octet-stream vcf
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(css|js)$ [NC]
RewriteRule ^([^/]+)/.+$ /$1/ [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/myTheme/style.css
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This line is an exclusion, because of the !:
RewriteCond %{REQUEST_URI} !\.(css|js)$ [NC]
That means if the URI ends with .css or .js then don't apply the rule. You can add others as needed. Say you don't want to redirect a URI like: /foo/bar/no-redirect/, then also add:
RewriteCond %{REQUEST_URI} !^/foo/bar/no-redirect/
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^([^/]+/).+$ /$1 [L,R=301]
I plan to have this as a URL:
https://SubDomain.domain.com/<locale>/Controller/action/param1/param2/?query=param3
in Lithium Framework (li3.me)
What is the purpose of the htaccess files in Lithium?
It should redirect me through .htaccess as:
https://domain.com/<locale>/Conttroller/action/param1/param2/?query=param3&subdomain=SubDomain
In Lithium framework there are 3 .htaccess files:
1. /.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
2. /app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
3. /app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Uncomment the line below, to enable HTTP authentication running PHP as a CGI.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !favicon.ico$
RewriteRule ^ index.php [QSA,L]
</IfModule>
I tried to edit the root /.htaccess file to get the subdomain name as a parameter without any success.
Pass subdomain as parameter
Dynamic subdomain rewrite htaccess
.htaccess Wildcard Subdomains
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_HOST} !mydomain\.com$ [NC]
RewriteRule ^(.*)$ app/webroot/$1?subdomain=%1 [L]
Do I have to rewrite rules in all 3 .htaccess files? If so, what are the changes needed?
Thanks!