ModRewrite index.php / redirect
That it may be useful to index.php in the main folder in order to lead, is that ultimately, otherwise there would be two URLs with the same content (duplicate content).
The redirection to index.php / is somewhat more complicated than most other diversions, one would normally be used. The problem is that Apache internally in the position to the index.php to call themselves internally but also to the. Htaccess or mod_rewrite rules.
ModRewrite index.php / redirect
As I recently mentioned that if I do not have a code for the. Htaccess knew with the man via the index.php to 301 / redirect and I can actually sowas ever had, I have in my projects “scrolls” and a Such .htaccess / mod_rewrite solution rausgesucht. More specifically, two.
Potentially harmful is if both the index.php or index.html as well as the “folder” / a site found by Google. This is Duplicate content – whether it carries a link or not, sooner or later it may happen by chance that the page in Google’s index slipping and potentially causing damage to the ranking. Who on the safe side wants to go – or already in trouble – which is advised wherever possible, the index page at / redirect.
In the following examples, the www.example.org nor your domain to be replaced.
But this is garnicht as easy as it first sounds. Some may already with constructs such as
RewriteRule http://www.example.org index.php [L, R = 301]
failed.
What happens is simple and easy to understand when you look at what the software that works in the background, does. But not everyone does and must, above all, not everybody.
Apache itself is trying, if / is a file called index.html or index.php, etc. forward. If he is, but per. Htaccess or mod_rewrite is refused and he instead on / redirect should lead to an infinite loop.
GET /
Internal call index.php
301 redirect to /
GET /
…
This can circumvent. The trick is that you not only check which file is trying to call, but the request verified:
Variant 1:
RewriteCond% (the_request) ^ [AZ] (3.9) \ / index \. Php \ HTTP /
RewriteRule ^ index \. Http://www.example.org/ php $ [R = 301, L]
Approved the request will be reviewed and that the request with 3-9 capitals begins (these are the access methods GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE and CONNECT – if WebDAV is supported additionally PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK) and then / index.php HTTP / stands.
A common request looks like this:
GET / index.php HTTP/1.1
Since we are on the client using HTTP version is not really realize you can end the test immediately after the last /.
If that is the case, will be forwarded index.php on http://www.example.org/. Internal Views of the Apache are not so obviously and we have not, therefore, the problem of infinite loop.
If that was too complicated, for there the whole even in simpler:
Variant 2:
RewriteCond% (IS_SUBREQ false)
RewriteRule ^ / index \. Http://www.example.org/ php $ [R = 301, L]
It examines whether it is a Subrequest that this is not the case, index.php rewritten, otherwise not.
I guess that option 2 is more secure, since they are not on the client request depends.
Moreover, one could also probably more general definite rules by which it would be possible with a line of all existing and emerging subfolder redirect. However, I have not been able to test and with the other variants also have no problem.
Popularity: 15% [?]













Leave a Reply