Link to home
Start Free TrialLog in
Avatar of ogdini
ogdini

asked on

.htaccess rewrite rule

Hello!

I have just set up a site that's showing the same page under 2 different URLS:

        1) http://www.site.tld/index.php?L=articlename
AND 2) http://www.site.tld/?L=articlename

I would really like to remove the index.php from the URL but only when it is appended by ?L=

Any help with the regular expression I need to use to do this would be greatly appreciated :D
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.tld [NC]
RewriteRule ^(.*)$ http://www.site.tld/$1 [L,R=301]
Options +FollowSymlinks
RewriteRule ^([a-z0-9]+)$ http://www.site.tld/?L=users.profile&id=$1 [r=301,nc]

Open in new window

Avatar of ravenpl
ravenpl
Flag of Poland image

but having
DirectoryIndex index.php
it's done automatically - both URL should work. Or You want to strip the index.php from URL? Cause one is incompatible with the other.
DirectoryIndex index.php # adds the index.php, You are stripping it, DirectoryIndex adds, You are striping - infinite loop?
Avatar of ogdini
ogdini

ASKER

Understood.... and thanks for your input and for pointing that out.

I actually need to strip index.php from the URL. 301 (permanently) redirecting it to the version without.
ASKER CERTIFIED SOLUTION
Avatar of BenMorel
BenMorel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial