Question

I have a situation where I'm trying to remove a subdirectory from certain URLS.

Here is what I'm trying to accomplish

http://www.example.com/shop/some_product should go to http://www.example.com/some_product

But

I need http://www.example.com/shop/customer/account to stay the same.

So essentially I need to rewrite anything shop/... except shop/customer/... shop/admin/...

Here is what I have tried

RewriteCond %{REQUEST_URI} !^/shop/customer
RewriteCond %{REQUEST_URI} !^/shop/admin
RewriteCond %{REQUEST_URI} !^/shop/sales
RewriteRule ^/shop/(.*) http://www.example.com/$1 [L]

Anyone have any advice here?

Was it helpful?

Solution

Thanks arkascha.

Turns out I had a couple problems. Here is what I ended up with:

in /shop/.htaccess

RewriteCond %{REQUEST_URI} !^/shop/(media|skin|js|customer|admin|sales|checkout)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /$1 [L]

I needed to not rewrite URLs matching a file or directory. Also, it seems that having /shop/ was a requirement for the RewriteCond, but would not work in the RewriteRule.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top