Hi i uploaded my website in below url : http://zendtest.com/
It shows file strucure in website. How to make public/index.php as default one.
File structure
public_html/
application
public
index.php
.htaccess
library
Anyone can help me ?
You have to define in Apache's httpd.conf DirectoryIndex. Like this:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Related
I have a specific website structure:
root:
styles.css
pages/index.html
folder_with_assets_1
folder_with_assets_2
folder_with_images
I've renamed index.html to index.php in order to get rid of .html extension in the URL
But the problem is that index.php is located not in a root folder, it's in pages folder.
Which right .htaccess rules could solve the problem in order to redirect requests to pages folder?
UPDATE
the screenshot with folder structure:
On the face of it, this just looks a standard front-controller pattern. Whether the front-controller is located inside a subdirectory or directly in the document root is largely irrelevant - the process is the same.
Assuming you are using the .htaccess file in the document root and there is no discernable pattern to the page URLs...
For example, using mod_dir FallbackResource:
FallbackResource /pages/index.php
Or, using mod_rewrite:
DirectoryIndex /pages/index.php
RewriteEngine On
RewriteRule (^|/)index\.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . pages/index.php [L]
UPDATE#1:
It's "onepage" website format with plenty of JS and CSS. There are only local URLs pointing to sections (href tag) and AJAX call to specific PHP files
In that case, it just looks like you need to change the DirectoryIndex - you don't need a front-controller pattern (as discussed above) at all.
For example:
DirectoryIndex /pages/index.php
Now, a request for the "homepage", ie the document root https://example.com/ will serve /pages/index.php.
UPDATE#2:
From your screenshot, it looks like directory listings (mod_autoindex) are enabled. These should be disabled at the top of the .htaccess file:
Options -Indexes
UPDATE#3:
From your screenshot, it would seem that what you have called "root" in your file structure is not actually your website's "document root", since you are accessing this location via a /test subdirectory, ie. localhost/test/. The directives above are assuming these files are located in the "document root", ie. localhost/ and there is no /test subdirectory. (Which I expect is how it is structured on your "live" environment?)
If your .htaccess file is located in the /test subdirectory and you are requesting localhost/test/ (as per your screenshot) then you will need to adjust this accordingly:
For example:
DirectoryIndex /test/pages/index.php
However, that will not work on the live site (assuming you don't have a /test subdirectory on live). Instead, you can simply omit the slash prefix, to make it relative.
For example:
DirectoryIndex pages/index.php
This should work OK in your case since you have a SPA (just a homepage URL).
I created a .htaccess file to set default index.html page to homepage.php only in root folder.
I already checked by adding DirectoryIndex homepage.php index.html, but this also work on all folders index pages.
Any body knows to sort this ?
Instead of DirectoryIndex use mod_rewrite rule in your site root .htaccess:
RewriteEngine On
RewriteRule ^(index\.html)?$ homepage.php [L,NX]
This will load homepage.php for landing page of your website.
Subdomain display 403 error due to "Options -Indexes" in .htaccess.
How to denied directory listing while permitting to Subdomain directory to work?
QUICK ANSWER
Define your DirectoryIndex in the httpd.conf
EXAMPLE
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AFTER THAT
Add an index.php or index.html file on your subdirectory.
The file you are adding must be the file you want to see when you access the subdirectory. The name & extension must match the values defined in the DirectoryIndex directive.
I want to access my symfony app in production env (http://www.sample.com/amateur1/web/app.php) from this url http://www.sample.com/amateur1.
To do that I moved the .htacces file to http://www.sample.com/amateur1/.htaccess with this contents:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
But when I go to http://www.sample.com/amateur1 shows a 404 Error, and prod.log isn't written.
I also used RewriteBase /amateur1/web/ because I don't know If RewriteBase path is relative to the DocumentRoot of the server, Or from the path where the .htaccess file is located. Also tried /amateur1 and /amateur1/ as RewriteBase due to this answer Symfony2: How to deploy in subdirectory (Apache)
With the three try's, The Exceptions page appears unstyled, and not loading any image. But then I get the following error in prod.log file:
[2013-02-15 02:06:47] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /amateur1/" (uncaught exception) at /home/u105859802/public_html/amateur1/app/cache/prod/classes.php line 5121 [] []
What I'm doing wrong ?
In your configuration, apache uses public_html as the document root
If Symfony2 is installed in directory /home/u105859802/public_html/amateur1, the Symfony public directory to serve is /home/u105859802/public_html/amateur1/web/
You should use
RewriteBase /amateur1/web/
But beware, it is not safe
You have to protect your symfony directories! (configuration is accessible)
Why don't you try moving your symfony files in your private area ?
You can rename the Symfony web directory to public_html
See how to do that in documentation cookbook
So, my recommendation structure looks like below :
/home/u105859802/
vendor
src
app
bin
public_html (web by default in symfony2) <- the only public directory
In most of the shared hosting, you can't override Apache settings in that case may need to wright a redirection rule in .htaccess file
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule !^projectName/ /projectName/web/app.php/%{REQUEST_URI} [L,NC]
this is the rule I used in my project .
You may need to provide full paths to your assets other ways they will not get loaded .
Could someone provide an .htaccess rule such that my index.php overrides my index.html?
Meaning that index.php, and not index.html, is served when I go to http://localhost.
That will do the job:
DirectoryIndex index.php index.html
In case there is no index.php the index.html file will be served instead.
This may work instead...
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ index.php [R=301,L]
In the apache configuration file (or .htaccess), set DirectoryIndex to index.php, instead of index.html
Here is an example:
http://www.javascriptkit.com/howto/htaccess6.shtml