4

I want to configure my htaccess file such when i type the folder name in small case or in upper case it will redirect to the same folder.

Currently i have my file as :

RewriteEngine on
#RewriteBase /ABC/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

The problem is when i try to access my controller giving the folder name in small case , it cannot find the controller.

That is if i try something as abc/contrller_name/controller_function it says path no found. Note:Working on Windows System and using XAMPP

1
  • I believe converting path's to controllers/folder names is more a job for php then for apache imo Commented Oct 8, 2015 at 7:23

4 Answers 4

1

In .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

In config.php (application/config)

$config['base_url'] = 'https://www.facebook.com/'; # set this to prevent HOST Injectio.
$config['index_page'] = '';
Sign up to request clarification or add additional context in comments.

Comments

0

This is the procedure for Ubuntu/Debian systems.

  1. From the command line, type sudo su to get root privileges.
  2. nano /etc/apache2/mods-available/speling.conf
  3. Type CheckSpelling on and hit ctrl-x, y to exit and save the file.
  4. type a2enmod and then speling and hit enter.
  5. type /etc/init.d/apache2 reload to reload apache.
  6. Mistype a url to test it.

Source making-apache-case-insensitive

According to Apache documentation, it is not possible, because case insensitivity is embedded in Windows OS. But you can "reverse the problem" and turn the Apache server under Linux/Unix being case insensitive. Just add the following directives to your .htaccess:

RewriteEngine On
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule .* index.php/$0 [PT,L]
RewriteRule (.*) ${lowercase:$1} [R,L]

5 Comments

@Gautam: Updated answer. Not sure though. Check if it works.
@Gautam: It should redirect your urls and make it as lowercase. Restart your apache after making changes.
Can u merge your set of lines in my code. Cause i'm weak in server programming. that would be a great help
@Gautam: Check if it works. I had hands on it long back.
not working it gives me a server error. anyways thanks for your efforts
0

Modify .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|FolderName1|uploaded|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /foldername/index.php/$1 [L]

Note: foldername is htdocs path.

Comments

0
Options -Indexes
RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.