i just needed some help i think its about time to ask some good felas for help.
here's my situation, i've been trying to use a symbolic link to fake my url just like this.
www.website.com/uk/controllers/method/etc
www.website.com/us/controllers/method/etc
aparently codeigniter failes to read the controller. the uk and us segment is a symlink to root directory so I expect it should point that to root. what made me sure that it points to the root is by viewing www.website.com/uk/ it works fine no erros all good. please help me on how to fix this. it might be i'm missing something like in htaccess or in route file. i've been having a headache about this for a day.
here's my current htaccess contents
Options FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /index\.(php|html)
RewriteRule (.*)index\.(php|html)(.*)$ $1$3 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I'm not sure if this will help but if you are using language class, then have a look at this extention:
https://github.com/EllisLab/CodeIgniter/wiki/URI-Language-Identifier
Try this code for redirecting /us/ and /uk/ to root:
Options FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /index\.(php|html)
RewriteRule (.*)index\.(php|html)(.*)$ $1$3 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^(system|application)
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteRule ^(?:us|uk)/(.*)$ /$1 [L,NC,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Related
Whenever I try logging into my site with a wrong user details, I get redirected from www.example.com/ to www.example.com/index.php.
I would like to remove index.php from my link.
Here is the content of my htaccess file, which does not work for me.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.php\ HTTP/
RewriteRule ^(.*)\.php$ /$1 [R=301,L]
RewriteRule ^login index.php [NC,L]
Check if this can work for you:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Check mod_rewrite module is enabled if not you first enable it.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Reference
htaccess documrntation
i am trying to force non-www to www and its working as aspected:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
now if i visit www.example.com/registration it works great.. but when i am accessing the same url from an link it works but adds index.php?/ in the url like this:
www.example.com/index.php?/registration
i am new to .htaccess programming.. i can understand i need ot modify the below lines.. but i dont know how to modify in such a way so that i does not add index.php?/ in the url...
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
any help or suggestion would be great help.. thanks in advance
Swap the order of your rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I have CodeIgniter setup in a sub-directory of a sub-domain. My htaccess file works for the following: http://subdomain.domain.com/subdirectory/
The working htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /subdirectory/
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]
However this does not work when I point a domain name http://www.mydomainname.org to public_html/subdirectory.
What I'm attempting to achieve is I'd like to use http://www.mydomainname.org/whatever/ to mask http://sub.domain.com/subdirectory/index.php/whatever
Is this possible? Is there anything I can add to my htaccess that will allow me to achieve this?
I attempted to use the htaccess answer here, but had no luck.
I think if you want both to work, you'll need to add extra conditions for the hostname, try something like:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# for main domain
RewriteCond %{HTTP_HOST} ^(www\.)?mydomainname\.com$ [NC]
RewriteRule ^$ /index.php [L]
RewriteCond %{HTTP_HOST} ^(www\.)?mydomainname\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?/$1 [L]
# for subdomain
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^$ /subdirectory/index.php [L]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(?:subdirectory/|)(.*)$ /subdirectory/index.php?/$1 [L]
I am having trouble after switching a customers site over to my linux cpanel webserver
accessing the site does work but the links do not,
I need it to stop it removing index.php after the domain name on all of the links (or start adding it!)
This is currently my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteCond %{HTTP_HOST} (.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Can anybody tell me how I can achieve this?
Thanks in advance
Change
RewriteRule ^(.*)$ /index.php/$1 [L]
to
RewriteRule ^(.*)$ /index.php/$1 [R=301,L]
I am having problems removing index.php from codeigniter-2. I remember using the same code before too & it worked perfectly fine, but it is not working on codeigniter-2.
I have checked the documentation & this question too, still of no help.
My .htaccess code is as follows:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
replace /index.php with /site_folder_name/index.php everywhere & be sure that your server supports mod_rewrite
Your new code should look like:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /site_folder_name/index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /site_folder_name/index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ /site_folder_name/index.php/$1 [L]
try this:
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
you have to re-write the .htaccess file for this.
maximum server work with this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
in godaddy server i have to write this. sometimes it works with above code in godaddy server.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1