Let's say I have a domain www.example.com
Now I want that, at this domain, my index page or main controller of the CodeIgniter folder should open without the folder name and the rest controller pages also without the folder name.
From: www.example.com/folder
To: www.example.com
I am hosting my files on hostinger. I don't want to remove my folder and export all the structure to base public_html.
I want my public_html to contain my CodeIgniter folder.
Any help would be appreciated!
To setup codeigniter on a subdirectory, you could try the following htaccess rule :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /YOUR_SUBFOLDER
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]
Change the YOUR_SUBFOLDER above to whatever subdirectory name you have.
Related
I have a wordpress website physically located in the "wordpress" subfolder of the root folder of the website. I manage to hide the subfolder "wordpress" in the URL with the following code:
.htaccess on root folder
RewriteEngine On
RewriteBase /
RewriteRule ^$ wordpress/ [L]
RewriteRule ^(.*)$ wordpress/$1 [L]
.htaccess in wordpress subfolder
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
However, I have another website in another subfolder let's call it "other-wp" and this needs to remain as it is, with the URL pointing to:
https://mywebsite.com/other-wp/
Since I managed to hide the "wordpress" folder in the URL, I am unable to acces my "other-wp" it says the page doesn't exist.
I'm not skilled with coding for .htaccess so i don't know what i need to do to fix it.
Could you help?
You need to implement an exception for that second resource:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/other-wp
RewriteRule ^/?(.*)$ /wordpress/$1 [L]
I also made some other modifications to that top level configuration file, just smaller optimizations. In general you should check if you can place such global rules in the actual http server's host configuration. Using distributed configuration files (".htaccess") is just a fallback if you have no access to the real configuration. They work, but come with disadvantages.
I have a problem with my .htaccess file. I would like to remove .html file extension on files that are in subdomain, but I can't do it.
Let's say that my website is david.xyz and subdomain calls sub (sub.david.xyz). This is my actual .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Note: This .htaccess file works with non-subdomain files perfect.
Can you help me?
Ohh... I solved my problem:
If you want to create site sub.david.xyz/some-web/, you need to create in the root folder of your subdomain folder named some-web and then create index.html file in it. The "beautiful URL" will be created automatically.
I've been struggling with this for a while.
My app structure is as follows:
- webroot
- app
- index.php
- .htaccess
I want that when someones goes to the webroot www.example.com to be redirected to the app folder where the app starts. However I want the URL to be www.example.com, not www.example.com/app/.
I suppose I'll need two htaccess? One in webroot and one in app.
Currently the /app/.htaccess looks like:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
This hides the .index.php file from the URL.
create one more .htaccess in the webroot with this lines
RewriteEngine on
RewriteBase /
RewriteRule !^app/ /app%{REQUEST_URI}
I have a cakePHP app working at http://domain1.com/domain2, and want to point http://domain2.com/ to this application.
I have done this change the document root of domain2 to public_html/domain2, but, when I go to: domain2.com all css, javascript and images are not loaded, with a message saying controller not found.
What I can do?
All domains have a folder with their domains without the TLD at domain1.com, I think if I create a htaccess and get the domain without TLD, and finally change rewriteBase, will work as expected, but don't know how to do this.
Current htaccess of domain2:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
You can try adding an htaccess file in domain2's document root with the following rules:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(css|js|png|jpe?g|gif|bmp|ico)$ [NC]
RewriteRule ^/?domain2/(.*) /$1 [L,PT]
This should remove the domain2 part of the links.
My codeigniter application directory structure is like
--application
--htdocs
--index.php
--.htaccess
--folder
--file1.xml
Now I have a url http://mysite.com/folder. This is showing the files list in the folder directory. What I want here is to rewrite this url to a controller on my site say 'html.php'.
Note: I do not want to redirect. I want the url to be same but instead of showing folder contents, I want to pass the control to a controller. What .htaccess rule should I write?
have you looked at url routing?
ie
$route['folder'] = "html"; //html is your controller
www.yoursite.com/folder
will "redirect" to yoursite.com/html but won't change the URL.
no need to mess with htaccess
edit:
RewriteEngine On
RewriteBase /
#ignored folders/files
RewriteCond $1 !^(index\.php|robots\.txt|img/|css/|js/)
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
obtained from - http://codeigniter.com/forums/viewthread/153228/
perhaps this is what you are after?