Welcome Guest, Not a member yet? Register   Sign In
Removing index.php using htaccess works on one server and doesn't work on others!
#1

[eluser]behnampmdg3[/eluser]
Hello friends;

I have a verison of the website on 2 differnet servers. I use htaccess to get rid of the index.php and it works fine on one server here is the link, please note the site is in a subdirectory.

But in second website; the other server it doesn't work and I need to have index.php in URL so it shows.

Whats should I change in my htaccess so it shows in the second website?

htaccess:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Thank you
#2

[eluser]Matthew Potter[/eluser]
You may need to set the rewrite base if it is not within the root of the server. For example, for your server, try this:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~sincity/

    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]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
#3

[eluser]behnampmdg3[/eluser]
Thank you Matthew your solution works fine.

Now how can I get the sub folders to work too? At the moment they don't work. I need a seperate htaccess in that folder I guess don't I?

Thank you
#4

[eluser]Matthew Potter[/eluser]
Perhaps I’m, missing something here… Is your sub folder another installation or a routing? If you’re using a new installation, may I recommend using HMVC? You’d be able to run the majority of the code as normal but you could have a complete administration MVC ability without needing to run a whole new instance within your server.
#5

[eluser]behnampmdg3[/eluser]
[quote author="Matthew Potter" date="1360042553"]Perhaps I’m, missing something here… Is your sub folder another installation or a routing? If you’re using a new installation, may I recommend using HMVC? You’d be able to run the majority of the code as normal but you could have a complete administration MVC ability without needing to run a whole new instance within your server.[/quote]Subfolder is another installation of codeigniter. The site is all up and running now I just need to get it to work. Thank you.
#6

[eluser]Matthew Potter[/eluser]
Although it is bad practice, you can install a new version into a sub-directory so long as you create a new .htaccess file with the appropriate Rewrite Base defined within that installation’s root directory and update it’s base url in the configuration.

Seriously though, if you install the HMVC into your base installation, it would be far easier:

Installation process:
Application->core +2 files
Application->third_party +1 folder
Application +1 folder called ‘modules’

Once it is installed, you just create a new folder in “modules” called “admin”. That new “admin” folder can now contain the folders “controllers”, “models”, “views”, etc… You can access them by exactly like you are now: [site_url]/module/controller/method/variables…
It also defaults to the expected:
http://site_url/module routes to http://site_url/module/module/index

For your URI schema, you would simply use “website_admin” instead of “admin” as the module name and primary controller.
#7

[eluser]behnampmdg3[/eluser]
[quote author="Matthew Potter" date="1360043708"]Although it is bad practice, you can install a new version into a sub-directory so long as you create a new .htaccess file with the appropriate Rewrite Base defined within that installation’s root directory and update it’s base url in the configuration.[/quote]I understand the solution you offer is very proper way of doing it. Meanwhile would you please guide on the .htaccess for the "bad practice" as I have to submit this job. Thank you
#8

[eluser]Matthew Potter[/eluser]
.htaccess file within the “website_admin” folder
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~sincity/website_admin/

    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]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

[root_folder]/website_admin/application/config/config.php line 42:
Code:
$config['base_url'] = 'http://staging.sincitynightclub.com.au/~sincity/website_admin/';
#9

[eluser]behnampmdg3[/eluser]
Hello, thank you for your help but doesnt find the css.

Also links go to a strange page. ( http://http//staging.sincitynightclub.co...n/home/log )
#10

[eluser]Matthew Potter[/eluser]
You’re missing the colon from the http. It may be my fault however, My base_url I gave you contains 2 http strings… Remove one. (sorry, it’s late here)




Theme © iAndrew 2016 - Forum software by © MyBB