Reputation: 952
I am updating urls of a project and have this old url: http://www.example.com/phones/nokia/
This folders phones
and nokia
are variable folders what don't exist anymore but I want to catch old traffic coming from them. In other words when someone visits the old url I want .htaccess
file to load store.php
which is located in the root directory.
How can I do this with htaccess so the url in the address bar stays http://www.example.com/phones/nokia/
but store.php
is still loaded.
Thank you in advance ! Thanks to Anubhava I have this code working for only 1 variable folder:
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
RewriteRule ^([^/]+)/index\.php$ store.php [L,NC]
How would the code above look like for 2 variable folders? Thank you
Upvotes: 0
Views: 199
Reputation: 785196
You can use one new rule for this:
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
RewriteRule ^([^/]+)/index\.php$ store.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ store.php [L]
Upvotes: 3