htaccess and canonicalization |
[eluser]Unknown[/eluser]
Hi - I am trying to remove index.php from the Root url i.e. so that... http://www.synthesisservices.com/index.php ... resolves to http://www.synthesisservices.com I have tried to find the answer in the other posts but don't seem to manage to find it. My current htaccess file is this... RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !index.php RewriteCond %{REQUEST_FILENAME} !rss2html.php RewriteCond %{REQUEST_FILENAME} !blog/(.*) RewriteRule (.*)\.php$ index.php?/main/$1 RewriteRule ^admin/main(/)?$ index.php?/admin [NC,L] RewriteRule ^admin/main/(.+)$ index.php?/admin/$1 [NC,L] RewriteRule ^admin/contacts(/)?$ index.php?/contacts [NC,L] RewriteRule ^admin/contacts/(.+)$ index.php?/contacts/$1 [NC,L] RewriteRule ^admin/marketing(/)?$ index.php?/marketing [NC,L] RewriteRule ^admin/marketing/(.+)$ index.php?/marketing/$1 [NC,L] RewriteRule ^admin/site(/)?$ index.php?/site [NC,L] RewriteRule ^admin/site/(.+)$ index.php?/site/$1 [NC,L] RewriteRule ^admin/articles(/)?$ index.php?/articles [NC,L] RewriteRule ^admin/articles/(.+)$ index.php?/articles/$1 [NC,L] RewriteRule ^admin/resumes(/)?$ index.php?/resumes [NC,L] RewriteRule ^admin/resumes/(.+)$ index.php?/resumes/$1 [NC,L] RewriteRule ^admin/papers(/)?$ index.php?/papers [NC,L] RewriteRule ^admin/papers/(.+)$ index.php?/papers/$1 [NC,L] # Redirect to remove trailing period or comma from URL request # with parameters, such as from forum with autolink, and force # www to always be in the URL: RewriteCond %{QUERY_STRING} ^(([^&]+&)*)[.,]$ RewriteRule (.*) http://www.synthesisservices.com/$1?%1 [R=301,L] # Redirect to remove trailing period or comma from URL request # with path, such as from forum with autolink, and force www: RewriteRule ^(([^/]+/)*)[.,]$ http://www.synthesisservices.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^synthesisservices.com RewriteRule ^(.*)$ http://www.synthesisservices.com/$1 [R=301,L] In the files which I have set up I have set the name of the homepage to be "index". If I remove this altogether I get... http://www.synthesisservices.com/.php Also in config.php. I have tried both $config['index_page'] = ""; and $config['index_page'] = "index.php"; Hope one of you experts can advise if this is possible. . Thanks.
[eluser]Daniel Moore[/eluser]
I have no idea why you're trying to rewrite "admin/main", "admin/contacts", and all those other directories. If these are your controllers and functions, then you are going about this all wrong. The following code is well commented so that you can customize it to your needs. Use the following: Code: # Code Igniter .htaccess file for the main index.php directory Open up your application/config.php and find the line that contains "$config['uri_protocol'] =". Check the value. Try each of the values listed in the comment above it one at a time ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') and see if that fixes the problem. Also make sure that config.php file has Code: $config['index_page'] = "";
[eluser]Unknown[/eluser]
Thanks a lot for your help Daniel. I will have a look at your recommendaitons and see if I can get it to work. Actually another guy developed this for me but I am sure he had some good reason for doing it this way as I had requested to have seo friendly urls. Thanks again. Richard
[eluser]Torus[/eluser]
@thewebseye: Yeah, your last programmer put together something that worked, but Daniel's code does the same thing in a much cleaner package. Hopefully you got everything up and running... @Daniel: Thanks for the tidy .htaccess file. I used it to take care of a few things I forgot. :-)
[eluser]Walter Coots[/eluser]
Yeah, thanks for this. Excellent, clean and comprehensive handling across multiple types of server configurations. I love it! |
Welcome Guest, Not a member yet? Register Sign In |