Remove indx.php
from URL; always redirect ??/
from ??/index.php
...including subdirectories, which may have their own .htaccess and index.php.
I'm using Apache with .htaccess.
I have a webapp with index.php in a subdirectory of the domain, say here:
example.tld/somedir/
But, it could be installed to any directory, such as these...
example.tld/anotherdir/
sub.domain.tld/
another.tld/
- Each has its own index.php and its own .htaccess, for our purposes
- On
example.tld/somedir/
:example.tld/
,sub.example.tld/
, et cetera also have their separate index.php and .htaccess, for their separate purposes - I need this to still work if placed in a subdir
example.tld/dir/
of a WordPress or October or SuitCRM installation atexample.tld/
.
Always hide index.php
via .htaccess
I want to make sure that:
- All above four / (root) addresses link to index.php in whatever same directory.
- index.php always redirects to / (root)
- Examples
example.tld/anotherdir/index.php -> example.tld/anotherdir/
sub.domain.tld/index.php -> sub.domain.tld/
another.tld/index.php -> another.tld/
I need something like this
RewriteRule ^.*$ /{$PWD}/index.php [L,QSA]
...and any Rewrite statements that must precede it.
These Questions do not provide an answer:
- htaccess redirect index.php to root (including subdomains)
- This does not address subdirectories, only subdomains
- This redirects
example.tld/dir/index.php
toexample.tld/
, but I needexample.tld/dir/
- htaccess remove index.php from url
- This only removes indx.php from
example.com/index.php/dir/subdir
- This does not remove index.php from
example.com/dir/index.php
like I need
- This only removes indx.php from
- .Htaccess redirect index.php
- This never got a working Answer
- This redirects
example.tld/dir/index.php
toexample.tld/
, but I needexample.tld/dir/
- Redirect to index.php of .htaccess dir
- This requires to specify
/dir/
, which I can't do. - This redirects
example.tld/dir/index.php
toexample.tld/
, but I needexample.tld/dir/
- The Answers don't work for the OP.
- This requires to specify
- htaccess remove index.php and index.php/
- This removes subdirectories from the URL also.
- Redirect all to index.php using htaccess
- This also requires to specify
/dir/
inexample.tld/dir/index.php
- Answer is:
RewriteRule ^.*$ /mvc/index.php [L,QSA]
, which I can't use.
- This also requires to specify
- .htaccess - simple redirect: index (with no extension!) / index.html / index.php to root
- Does not address subdirectories, which I need.
- Removing index.php from URLS with .htaccess
- This redirects
example.tld/dir/index.php
toexample.tld/
, but I needexample.tld/dir/
- This redirects