Welcome Guest, Not a member yet? Register   Sign In
Mod Rewrite Not Working Properly
#1

[eluser]Pawel K[/eluser]
Hello,

I followed the user guide to get rid of index.php from my URLs. But I can't get this to work. This is my .htaccess file located under /home/mesa/public_html/cart:

Code:
RewriteEngine on
RewriteBase /home/mesa/public_html/cart/
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

But this will not work. When I go to /cart/admin it always fetches the default welcome message. If I go to /cart/index.php/admin then it works just fine. I added RewriteBase after searching the forums, it didn't help me.

Any help with this problem would be greatly appreciated, I searched around the forums and tried various solutions with no luck. Could it be an issue with the fact that my installation is in a subdirectory of the document root? I didn't think that mattered.
#2

[eluser]tomcode[/eluser]
Try it taking out the slash in front of index.php :
Code:
RewriteRule ^(.*)$ index.php/$1 [L]
#3

[eluser]Aken[/eluser]
Your RewriteBase is wrong, it does not have to do with the physical location of your files, it has to do with the base directory of the URL the user is visiting. More info here.

I'd recommend using a better written .htaccess. Check this one out, and make sure to customize it to suit your application.
#4

[eluser]tomcode[/eluser]
[quote author="Aken" date="1273471820"]Your RewriteBase is wrong, ... [/quote]
Totally right. Guess I better stop posting late in the night.


[quote author="Aken" date="1273471820"]....I'd recommend using a better written .htaccess. [/quote]
Me, too, I use that flavour, though without the system and app part.
#5

[eluser]Unknown[/eluser]
For Directory Root "/home/mesa/public_html/", try this:

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

[eluser]Pawel K[/eluser]
Thank you for all the replies, Aken the link you gave me worked like a charm after changing a few of the lines. I also appreciate the RewriteBase explaination, makes sense.

I have one more question. I would like to use the .html extension which I set up in the config file. So instead of admin/login I want admin/login.html. Can anyone offer suggestions on how to do that with my htaccess file? Thanks.

Current file:

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

    #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]

    #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>




Theme © iAndrew 2016 - Forum software by © MyBB