I want to redirect an old url to a new url like this:
Redirect 301 www.domain.ro/index.php www.domain.ro/
But in my case i have a dynamic subdomain , and i don't know how to build the line:
Redirect 301 www.domain.subsdomain.ro/index.php www.domain.subsdomain.ro/
Now,besides that the subdomain is dynamic, also the protocol can be http or https and the user can type in the www or not, so the line would look like:
Redirect 301 domain.{*}.ro/index.php domain.{*}.ro/
{*} - wildcard that matches every alphabetic char between dots
You don't meed to use domain name in target when it is same as the source URL. Besides you cannot even main host name in Redrect
directive.
Just use this rule using mod_rewrite
to remove index.php
:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php[?\s] [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]