301 redirect from "/index.html" to root if index.html not exist
2,423
Use it like this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*?/|)index\.html$ / [L,R=301,NC]
Related videos on Youtube
Author by
ayublin
Updated on September 18, 2022Comments
-
ayublin over 1 year
Possible Duplicate:
How to enable PHP short tags ?I am using
Apache Friends XAMPP (Basis Package) version 1.7.3- Apache 2.2.14 (IPV6 enabled)
- MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc
- PHP 5.3.1 (PEAR, Mail_Mime, MDB2, Zend)
and i am running php files, that i code with
<? ?>
tags not<?php ?>
. but the apache server won't execute my code, but if i try with<?php ?>
tags, the code works. Anyone know how to enable the server to execute php code with<? ?>
tags ?-
zerkms over 13 yearsWhy don't you use
<?php
then everywhere, the less configuration-dependent way of specifying php code? -
profitphp over 13 yearsIts best to not use short tags though, they are on the way out, and you will someday have to go and change them all.
-
Marc B over 13 yearsYou can enable the short tags, but take it as a sign that you'll have to start updating your code: short tags are deprecated and could vanish in any future version of PHP, leaving you with a large pile of unusable code.
-
netcoder over 13 years@Marc B: Short tags are not deprecated, although I agree they should not be used.
-
ayublin over 13 years@jasonbar: ohh yeah, it's also answer to my problem, sorry i didn't realized it's existencene before, should i delete this ? @all: ohh, well, thank you very much everyone, i don't know if it's deprecated, so it's better for me change everything before it's too late.. once again thanks!
-
Marc B over 13 yearsAh, I see now that the decision was made to leave them in. Good enough. Thanks for getting me to go look.
-
Felix Kling over 13 years@Marc B: They might not be deprecated but that they are disabled by default is a strong sign not to use them.
-
ceejayoz over 13 yearsWell, he needs to stop using short tags. This is just a temporary workaround until the ability to use them disappears entirely.
-
Admin about 11 yearsDoesn't work, this rule show 310 redirect on all pages. (I mean firs rule) 2nd rule don't change anything
-
Admin about 11 yearsTry this one RewriteEngine On RewriteCond %{REQUEST_FILENAME} ^(.*)/index.html$ RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^.*$ - [NC,L] RewriteRule ^(.*)/index.html$ /test.php?a=$1 [R=301,L,NC]
-
Admin about 11 yearsRewriteRule is not properly visible in comments, so updated by answer
-
Admin about 11 yearsThe same 404error Thanks for try, maybe you know where can be this problem?
-
Admin about 11 yearscan you check Firebug -> Net? Is RewriteRule is giving 404 or it gives 404 after redirecting to example.com/$1
-
Admin about 11 yearsDoesnt work, maybe you know reason for this?
-
Admin about 11 yearsHave you ever tried to run the code by itself? Now, check the updates' new code if it will going to work.
-
Admin about 11 yearsOnly 404 without redirect