Code: Select all
RewriteCond %{REQUEST_FILENAME} !-d [NC]
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-d [NC]
Thanks, for pointing that out. I had actually not run into this problem because I was using Firefox's URL auto-complete. Thanks for finding it.Ryno wrote: Hey Elijah,
Just tried your .htaccess settings and they work great for me.
Only problem is when I try to access /admin or admin/ I get a 404 error?
Thanks iNSiPiD for leading me to a solution. The above rule didn't work, but it I changed the [R] to a [L] it worked ([R,L] would also work, but we don't need to redirect the browser).iNSiPiD wrote: The rewrites above only account for existant files, not directories.
You need to create a rule for each directory you'd like access to. This also has the side affect of disallowing entry to folder views which, in most cases, is a good thing.
Just throw this into your htaccess file above the main rewrite rules.
RewriteRule ^/?admin/?$ /admin/index.php [R]
Code: Select all
# Make /admin/ work.
RewriteRule ^/?admin/?$ /admin/index.php [L]
Code: Select all
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
Options +FollowSymLinks
RewriteEngine on
# Make /admin/ work.
RewriteRule ^/?admin/?$ /admin/index.php [L]
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
I think it should from reading the manual, but I just tried it out and was unable to use it to prevent the 404 error for /admin/.Ted wrote: Shouldn't
look for existing directories first and then continue on if it's not found?Code: Select all
RewriteCond %{REQUEST_FILENAME} !-d [NC]
Thanks Ted!Ted wrote: Shouldn't
look for existing directories first and then continue on if it's not found?Code: Select all
RewriteCond %{REQUEST_FILENAME} !-d [NC]
Code: Select all
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
Options +FollowSymLinks
RewriteEngine on
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
My latest .htaccess file is this:.htaccess: Invalid command 'php_flag', perhaps mis-spelled or defined by a module not included in the server configuration
Code: Select all
Options +FollowSymLinks
RewriteEngine on
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Code: Select all
#Show mod_rewrite URLs in the menu?
$config['assume_mod_rewrite'] = true;
#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';
The code above defaults to having pages have urls like dir/subdir/page/ and if someone visits dir/subdir/page (without the slash) they will get a 301 redirect to the page with the slash dir/subdir/page/Russ wrote: I'm no expert at this stuff, but I seem to remember that some search engines add a trailing slash to the path so instead of:
dir/subdir/page
you get
dir/subdir/page/
which could case problems. Could the $ not be /?$ or soemthing like that - I'm no expert on this and your code may already do this?