I want to remove index.php from url but so far i couldn't succeed it. I'm using Wamp server on my local and Apache on remote server..
In local root directory, my project files are located in a subfolder like
www/project/index.php
I can access web pages like
localhost/project/index.php/home
localhost/project/index.php/messages/?mId=3
I just want to access it like
localhost/project/home
localhost/project/messages/?mId=3
I already tried some .htaccess rewrite rule but couldnt make it.
Here's how you need to organize:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
</ifModule>
And then you will have everything as you need.
You will want to use url rewriting with a .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Put a .htaccess with this content in each subfolder.
Related
Running three vue.js applications with vue-router on apache sever.
The HTACCESS redirects all non existing paths to /folder1/index.html. Now I want to include a redirect when the user accesses /folder2/success > /folder2/index.html instead of folder1/index.html
My current HTACCESS file looks as follows, however it isn't working it still redirects to folder1.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder1/index.html [L]
RewriteRule /folder2/success /folder2/index.html [L]
</IfModule>
Really stuck on this any suggestions would be greatly appreciated!
Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.
Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.
Your .htaccess file would look something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteRule ^folder2/success /folder2/index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder1/index.html [L]
</IfModule>
Inside my drupal project www.example.com I have codeigniter project folder which is not running without index.php in the url.
Pls suggest any solution
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
In codeigniter URL rewriting will differ for servers. For linux you should use .htaccess file and for windows you should use web.config file. You can get those files by google it.
My CodeIgniter project is placed inside sub-folders and I want to hide those two sub-folders with .htaccess.
Everything is working fine but my current URL looks like this:
example.com/folder1/folder2/ci_project/class/function/$id
I want this to be:
example.com/class/function/$id
Now, I am using this simple .htaccess code in order to remove the index.php from URL:
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Any Ideas?
when i use the following code in htaccess file inside folder1/folder2/ci_project, it does hide the sub directories but i get the error "Object not found"
RewriteCond %{REQUEST_URI} !^/folder1/folder2/ci_project/
RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
Move your current .htaccess file from your ci_project/ to the root of domain, and replace these code inside it:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(robots\.txt|favicon\.ico|public)
RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
</IfModule>
In this case, you should place your public files in a folder like public at the root of the domain.
You should add other folders (like public) to RewriteCond if you don’t want them to be treated by RewriteRule.
If multiple application are exist in the same domain, you might want to consider this option:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
</IfModule>
I'm having problems to browse normal html pages inside my additional domain, example-domain.com
here's my file structure
public_html
-css
-img
-js
example-domain.com <- get server error
- index.html
-products.html
- contact.html
-system
.htaccess
index.php
I use codeigniter framework in the main site, and simple html within the additional domain
example-domain.com , when i put the url to browse example-domain.com, i get a 500 internal server error I think it's due to my .htaccess file i 'm using for the main domain. How can I modify it to load simple .html files inside my additional domain as well.
my .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|img|css|js|uploads|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]
Currently, what I see, you are trying to do the redirect, if the requested URL is not a file and not a directory. It can be done, using these directives:
RewriteEngine On
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I'm using codeigniter, and I tried to remove index.php from url by creating .htaccess file
and it contents:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
this way is working will at xampp server.
but when I uploaded the site, unfortunately there was a problem appeared:
I have a folder called files and it content sub folders: images, css, js, swf, upload.
and every file at those folders can't view, and the browser said there the file not found.
any help ploese.
Just make sure you exclude those too:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|swf|upload)
RewriteRule ^(.*)$ /index.php/$1 [L]
This is my .htaccess file. My understanding is that for any file or directory which has access attempted and doesn't exist, it will forward onto Codeigniter.
Anything which does exist will work fine and will not require individual exclusion. This will save time and hassel each time you add a new directory or folder as it wont require you to edit this file.
RewriteEngine on
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Works for us, but my understanding may well be incorrect. Hope it helps
try this one which i think will solve your problem ..
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
you have to tell your server not to handle those directories over to index.php and the line which work for this is :
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)
Here is my .htaccess file - which should work for you:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# activate URL rewriting
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(files|css|js|swfimages|assets|uploads|captcha)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt|crossdomain\.xml|maintenance\.html)
# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
thank you. this worked fine:
RewriteEngine on
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I have another website and next index.php I have a folder called files, and this one content alot of folders should I have to put all names of them and names of sub-directories in them?