Welcome Guest, Not a member yet? Register   Sign In
Using .htaccess to remove index.php (yes another one)
#1

[eluser]peterbz[/eluser]
I know you're probably thinking "Oh my.. another one of these problems!" Yes, I did check the forums for a solution, but it doesn't seem to work.

I've set up Apache (version 2.2) on my Windows PC, edited the httpd.conf to allow mod_rewrite, and placed a .htaccess file in the root of my CodeIgniter directory, but it doesn't seem to do the trick.

My apache running dir is C:\htdocs
I've placed the .htaccess in C:\htdocs\Websites\WeddingPlace\
(I've renamed the CodeIgniter folder to WeddingPlace, so the index.php is inside directory WeddingPlace)

Here's the changes in httpd.conf
Code:
<Directory "C:/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
</Directory>

and I uncommented the line:
Code:
LoadModule rewrite_module modules/mod_rewrite.so

Here's my .htaccess:
Code:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^/(.*)$ /index.php/$1 [L]

I've also changed the config.php file in Codeigniter:
Code:
$config['base_url']    = "http://localhost/Websites/WeddingPlace/";
$config['index_page'] = "";

I've restarted Apache many times after each edit to httpd.conf, so it shouldn't be a problem of restarting.

If anyone can help, it'd be much appreciated. Thanks!
#2

[eluser]hugle[/eluser]
Hello.

what error do you get ?

I have zero experience with Windows servers, but:

have you tried to put your system directory with a index.php file right into:
C:/htdocs

And check if it works ?
#3

[eluser]peterbz[/eluser]
It gives me a 404 Not Found

It works when I try http://localhost/Websites/WeddingPlace/i...hp/welcome
but when i try http://localhost/Websites/WeddingPlace/welcome it doesn't work

I also tried to put the whole thing right in C:/htdocs but that also doesn't work


I think the problem is that I don't have mod_rewrite properly enabled in Apache since I tried phpinfo() and I couldn't locate mod_rewrite in there. If anyone can help me properly configure Apache, it'd be great.
#4

[eluser]hugle[/eluser]
Hello.

try this .htaccess:

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

put it into Websites/WeddingPlace/.htaccess


P.S.
are you sure htaccess file is working ?
Try changing from :

Code:
<Directory "C:/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
</Directory>

to:

Code:
<Directory "C:/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>
#5

[eluser]uptime[/eluser]
Just to make sure you've tried it...

Try to change this:
Code:
RewriteRule ^/(.*)$ /index.php/$1 [L]

To that:
Code:
RewriteRule ^/(.*)$ /index.php/?$1 [L]
#6

[eluser]peterbz[/eluser]
Thanks for replies, but I've tried your above steps and it still doesn't work.

I think it's my Apache configuration, because I tried phpinfo() and I could not locate mod_rewrite on there.
#7

[eluser]ray73864[/eluser]
seems like you are doing this from a subdirectory, in which cause you need the RewriteBase (i think it is) set so that the .htaccess knows where it is working from.

also, phpinfo() only shows config stuff for php, mod_rewrite is an apache thing so you wouldn't see it in there anyway.
#8

[eluser]uptime[/eluser]
ray73864 - good point, I didn't notice it was a subdirectory.

peterbz - Does it give you the server's 404 or CI's 404?
#9

[eluser]peterbz[/eluser]
It gives me server's 404

So what should the RewriteBase be?

EDIT:

I tried this but still doesn't work:
Code:
RewriteEngine on
RewriteBase   /Websites/WeddingPlace/
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^/(.*)$ /index.php/$1 [L]

The htaccess file is inside C:/htdocs/Websites/WeddingPlace/
#10

[eluser]uptime[/eluser]
The server's 404?

What if rename .htaccess (to disable it) and go to index.php - do you get to CI's welcome page?




Theme © iAndrew 2016 - Forum software by © MyBB