php - access a folder in 'public' directory of laravel

640

How can I access a folder placed in thepublic directory of my default laravel installation. This question is for both -testing as well aslive purpose.

While Testing-

I am testing on windows using XAMPP's apache http server. I have placed my app's root folder in thehtdocs folder of XAMPP. Thus, when I try to access a folder in public directory,'localhost/myappname/public/blog' it redirects me to'localhost/blog'.

I don't want this behavior. I want it to pick up the'index.php' file present at'localhost/myappname/public/blog/' location. But it doesn't do so.

While Live-

I have my site live on ubuntu with apache http server. When I try to access'mysitename.com/blog' in the firefox, it gives me this error -

Firefox has detected that the server is redirecting the request for this 
address in a way that will never complete.

I have no hint about what's wrong. I have tried spending two days working with laravel's default.htaccess file(inpublic folder) and apachehttpd.conf but still not able to resolve it. Have searched a lot over stackoverflow and google but still no clue about where I am wrong. Please guide me.

Added:

The content of.htaccess file is -

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

RewriteEngine On

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

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

40

Answer

Solution:

You just need to comment this line in your.htaccess file.

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

Comment it or strip out from the file. This will solve both your directory/blog issue as well as redirect loop issue.

105

Answer

Solution:

I used theAlias feature of apache to overcome this problem. I added an alias for'/blog' in my virtual host configuration.

People are also looking for solutions to the problem: php - Symfony 2 Routing

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.