Reputation: 1009
I know that this question can be the DUPLICATE of another question but after all I was unable to find an appropriate answer for my question.
I am trying to rewrite url
with .htaccess
that is placed in the root directory of my localhost
The file contains this code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !home
RewriteCond %{REQUEST_FILENAME} !seller
RewriteRule ^([^/]*)/$ stores/$1 [NC,L]
RewriteRule ^([^/]*)$ stores/$1 [NC,L]
Problem:
If the original url is as http://localhost/stores/mystore
then it can be access as http://localhost/mystore
but this new url redirecting it to original url as first which should not do.
How it can be solve?
Thanks in advance.
Upvotes: 2
Views: 39
Reputation: 785531
if stores/mystore
points to a directory then mod_dir
will add a trailing slash after your rewrite rules have executed.
Try these rules:
Options +FollowSymLinks
RewriteEngine On
# add trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !(home|seller)
RewriteRule ^([^/]+)/?$ stores/$1 [L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.+[^/]$ %{REQUEST_URI}/ [L]
Upvotes: 1