I am an .htaccess newbie and am having problems in removing a folder name from my sites URL.
It is currently: www.mydomain.com/engine
I have an expression engine site in a subfolder (named engine) of my hosts html folder. In this folder I have an htaccess document in which I have followed the directions in the expressionengine user guide to remove the index.php? from the URL succesfully, with:
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I would now like to remove the "engine" referring to the subfolder from the URL too.
I have made numerous attempts going on advice in previous questions but have had no success.
On viewing www.mydomain.com, with any of my attempts I recieve:
Forbidden. You don't have permission to access / on this server.
I thought this could be a permissions problem, but this containing html folder has the same permissions as the "engine" folder which allows access.
Can anybody help with the .htaccess code i require?
yeh, the above rules don't apply to homepage url because it's a directory (doesn't pass the third RewriteCond), use the code below:
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond $1 ^$
RewriteRule ^(.*)$ /engine/index.php?/ [L]
Related
Hello.
I have a site protected by a .htaccess which redirects everything to the /pb directory except the /cron directory which is directly accessible (later it will be protected).
My htaccess works (it redirects as I want) BUT I cannot load the .css .js files that I call directly into my index page.
Do I have to put a new .htaccess in my /pb directory to allow access to .css or can I do it in my root htaccess ? I do not understand.
My .htaccess file (the https lines can't be removed "hostinger")
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?XXXXXXXXX.net
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(cron) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [L]
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule (.+) pb/$1 [L]
RewriteRule (.*) pb/index.php?path=$1 [L,QSA]
order deny,allow
deny from all
allow from XX.XXX.XXX.XX
Thanks for your help
First thing first, I have fixed your htacces rules file, comments have been made inside Rules file. Have your htaccess rules file like as follows style, make sure its placed in same folder where pb folder is there. Also please do clear your browser cache before testing your URLs.
Options -Indexes -MultiViews
RewriteEngine on
##Apply https rules here.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?XXXXXXXXX.net [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
##Handling base URI of site.
RewriteRule ^/?$ pb/ [R=301,L]
##Blocking pb uri pages non existing ones.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [NC,L]
##making all uris which are files to pb folder.
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule ^(.+)/?$ pb/$1 [L]
##Making non existing uris to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ pb/index.php?path=$1 [L,QSA]
order deny,allow
deny from all
allow from XX.XXX.XXX.XX
JS/CS rewrite/redirect:
You may need to use base tag to fix your js and other relative resources. If you are linking js files using a relative path then the file will obviously get a 404 because its looking for URL path. for example if the URL path is /file/ instead of file.html then your relative resources are loading from /file/ which is not a directory but rewritten html file. To fix this make your links absolute or use base tag. In the header of your webpage add this <base href="/"> so that your relative links can load from the correct location.
I'm having a weird issue with expressionengine. I have a website home page which i have created a template group for called "index". Inside index template group theres the index page template which works as expected, www.domainname.com/ goes to the index.php page.
What I have an issue with is if I add other template groups, those urls will look like this:
www.domainname.com/index.php/template_group_name/template_file
I'm not sure what am I doin wrong, as in their docs the url should look like this:
www.domainname.com/template_group_name/template_file
How do I remove that index.php from the domains?
You will need to fix this with your .htaccess file in the root of your public_html.
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
found it, it was hidden somewhere in their manual, anyone else having the same issue, paste the following in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
source:
https://docs.expressionengine.com/latest/installation/best-practices.html#removing-indexphp-from-your-urls
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteRule ^(.*)$ /drupal/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
The folder structure is as follows
public_html
/apps
/drupal
Currently when we give www.domainname.com it redirects to drupal folder and our website is displayed. We have some apps installed in apps folder and want to access it using the url www.domainname.com/apps and when we give this it goes to drupal framework and we get page not found.
What rule should we write to that when we give /apps in the url it should get into apps folder and all other times it should go to drupal folder.
Any help is appreciated. Thanks.
It looks like you're missing a line in the rewrite rules that you posted, but you just need to exclude the apps folder the same way you are excluding the drupal folder:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteCond %{REQUEST_URI} !^/apps/
RewriteRule ^(.*)$ /drupal/$1 [L]
As the title says, I am using Code Igniter, need to point to a folder on godaddy hosting account, while removing index.php and adding www.
My current settings work for the main page only, also all the css and js files get included. However, none of the internal links work and i get 500 internal server error.
all the current settings:
In the domain settings, it is pointing to a folder on my hosting, working correctly since the main site loads.
config.php
$config['base_url'] = 'http://www.example.com';
$config['index_page'] = '';
htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
Edit: Managed to solve it, all that was missing was this line
RewriteBase /
i am not sure whether it will work for you or not but i am using it and its working fine for me.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
just paste the code in your root directory .htaccess file. Please let me know the status.
I am having issues with htaccess redirections. Following is the issues I am having.
The root folder to which the main domain actually points has the following folder: "example"
example.com is actually internally linked to the path "root/example/" rather than "root/". This is done using the following htaccess code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/index.html [L]
The folder "exmaple" has the following subfolders: newexample, newexample_beta
If I go to the URL "example.com/newexample", the URL needs to be internally linked to "root/example/newexample". But the URL redirects me to "example.com/example/newexample/"
could you please let me know what needs to be done