[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

correct pretty URLs in .htaccess Apache

Hi,

I have this URL:
http://localhost/test/trunk/php/l4/public/index.php

and it works fine. I'm using Laravel 4 btw.

I added some code but this URL doesn't work:
http://localhost/test/trunk/php/l4/public/users

But this funny-looking URL works though:
http://localhost/test/trunk/php/l4/public/index.php/users

So I know the program is working but how I can fix it so the URL works:
http://localhost/test/trunk/php/l4/public/users

Just fyi, I was reading this page under the "Routing" section and just added that small tidbit of code:
http://laravel.com/docs/quick#installation

I have this in my .htaccess file:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /

    # Redirect Trailing Slashes...
    #RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Open in new window


How can I fix it to make this work in .htaccess?

Thank you and Father bless<><
0
Victor Kimura
Asked:
Victor Kimura
  • 2
  • 2
2 Solutions
 
theruckCommented:
you do not need a rewrite rule for the http://localhost/test/trunk/php/l4/public/users url to work if there is an index page in the public folder. just comment out the RewriteRule ^ index.php [L] and see
if there is a specific URL you need the /users URL to redirect. please post it here
0
 
Victor KimuraAuthor Commented:
@theruck, if I comment out the RewriteRule then don't I need to comment out the RewriteCond's too since it's the rule based on the previous conditions and it's the last rule?

It's the Lararel framework so there is no public/users folder. I don't know the inner workings of the framework but it's supposed to work. The youtube videos I've seen have used a Vagrant box for it so maybe it'll work then.
0
 
theruckCommented:
as i do not understand your talk about frameworks and youtube which is absolutely irrelevant in your problem.
try this
http://www.generateit.net/mod-rewrite/index.php
0
 
Victor KimuraAuthor Commented:
Also, what worked for me was that I had to enable the mod_rewrite in Apache because by default it's not enabled for WAMP which is odd I think since it's so widely used. But then I had to restart my computer or log out and then log back in again because it's tied to the Windows session. Hope this helps others too. Father God bless<><
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now