.htaccess to CodeIgniter not work?

why this .htaccess to CodeIgniter not work?

RewriteRule ^site/?$ site/web_design [L]    # Handle requests for "site"

Probably because it doesn’t start with


RewriteEngine On

:wink:

no, full .htaccess:

RewriteEngine on

RewriteRule ^([a-z0-9_-]+)\\.html$ index.php/page/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|asset|robots\\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

# this not work other work true
RewriteRule ^site/?$ site/web_design [L]


go to url …/site have error:

404 Page Not Found

The page you requested was not found.

You need to put that rule before the other rules:


RewriteEngine on

RewriteRule ^site/?$ site/web_design [L]

RewriteRule ^([a-z0-9_-]+)\\.html$ index.php/page/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|asset|robots\\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

no, not work
do must change this?

$config['uri_protocol']	= 'AUTO';

I don’t know code CodeIgniter, so I have no idea if there is anything that must be changed in there …

ok, i change of AUTO to PATH_INFO:


$config['uri_protocol']	= 'PATH_INFO';

that true…
don’t know find problem on the future or no!?


 
RewriteEngine on
 
RewriteRule ^([a-z0-9_-]+)\\.html$ index.php/page/$1 [L]
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|asset|robots\\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
 
# this not work other work true
RewriteRule ^site/?$ site/web_design [L]
 

RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]

Try something like:

RewriteRule ^p/([a-zA-Z0-9_-]+)$ index.php?page=$1 [L]
COLOR=#008000[/COLOR]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

^^ If it is not a filename or a directory and the $1 if not index.php asset or robots.txt then redirect it all to index.php. Also need to use {requesturi} like this:

RewriteCond %{REQUEST_URI} !^(index\.php|asset|robots\.txt)

[COLOR=red]^^ Essentially, this whole thing is illogical and needs rewritten ^[1]

Also try this: mod_rewrite rewriterule generator :: Webmaster Toolkit


  1. /COLOR ↩︎