Welcome Guest, Not a member yet? Register   Sign In
htacces takes me to localhost instead of removing index.php
#1

[eluser]behnampmdg3[/eluser]
Hello;

I am trying to get rid of index.php in url, but it shows me the local host (one directory above what I want) instead of main folder. What am I doing wrong?

Thank you

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
#2

[eluser]InsiteFX[/eluser]
Code:
php_value default_charset utf-8

Options FollowSymLinks
DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And make sure you place it in the directory with index.php
#3

[eluser]behnampmdg3[/eluser]
[quote author="InsiteFX" date="1355828511"]
Code:
php_value default_charset utf-8

Options FollowSymLinks
DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And make sure you place it in the directory with index.php
[/quote]Hello;

This does the same. Takes me to localhost!
#4

[eluser]davidMC1982[/eluser]
Do you have your site in a subfolder under your webroot? If so, you may want to try InsiteFX's .htaccess but change:

RewriteBase /

to

RewriteBase /nameofsubfolder/
#5

[eluser]InsiteFX[/eluser]
And what happens if you donot use an .htaccess file?
#6

[eluser]behnampmdg3[/eluser]
[quote author="behnampmdg3" date="1355827364"]Hello;

I am trying to get rid of index.php in url, but it shows me the local host (one directory above what I want) instead of main folder. What am I doing wrong?

Thank you

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
[/quote]Thank you for your replies. The reason it was not working was because the whole site was in a sub directory. Now I moved it to the main directory but now it deosn't find the css files! This is the domain. If you view source you see the url to css is something like http://ben.soundtraffikmusic.com/css/styles.css which does exist but it can't find it. What am I doing wrong?

This is how I import the css
Code:
<link href="<?php echo base_url();?>css/styles.css" rel="stylesheet" type="text/css" />
#7

[eluser]InsiteFX[/eluser]
Try this:
Code:
<link href="<?php echo base_url('css/styles.css'); ?>" rel="stylesheet" type="text/css" />

This is the correct way to use base_url()

Also check to make sure your config base_url is set correct, or leave it blank and CI will try to
figurre it out for you.
#8

[eluser]behnampmdg3[/eluser]
[quote author="InsiteFX" date="1355887000"]Try this:
Code:
<link href="<?php echo base_url('css/styles.css'); ?>" rel="stylesheet" type="text/css" />

This is the correct way to use base_url()

Also check to make sure your config base_url is set correct, or leave it blank and CI will try to
figurre it out for you.
[/quote]Hello;

Thank you for your reply. Unfortunately it didn't work.
Code:
<link href="<?php echo base_url('css/styles.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('css/home.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('css/'.CSS.'.css');?>" rel="stylesheet" type="text/css" />

Still clicking on css link from the source takes me to 404!

base_ulr in cofig is blank, I checked that.

Please dont give up on me. Thank you

#9

[eluser]InsiteFX[/eluser]
What OS and Server software are you running? Your problem seems to be a setup problem or a bad
download of CodeIgniter.
#10

[eluser]jojo777[/eluser]
Hi! try this!

This is my normal .htaccess file when i work at localhost. For example I've in /var/www folder my projects, so:

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

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

That should work fine!




Theme © iAndrew 2016 - Forum software by © MyBB