-1

This is my .htaccess file

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.\*)/(.\*)$ web/$1.php [L]<br />

RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.*)$ web/$1.php [L]<br />

I want the following URLs

http://www.example.com/index

http://www.example.com/index/

http://www.example.com/index/admin

http://www.example.com/index/admin/

http://www.example.com/index/admin/123......

all redirect to

http://www.example.com/web/index.php

but if use my code,
it cannot redirect more than two levels directory...
How can I adjust the .htaccess file?

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
Azure Chen
  • 859
  • 1
  • 12
  • 21
  • Have a look at the answer on http://stackoverflow.com/questions/5282566/using-mod-rewrite-to-simulate-multiple-sub-directories. – Dirk-Willem van Gulik Aug 18 '12 at 10:42
  • I already see this answer you paste, but it cannot solve my question.(Maybe I didn't get enough skill about it). Because I need to get the variable like "index" to redirect to "web/index.php" – Azure Chen Aug 18 '12 at 15:17
  • What do you want to happen to the /admin/123 stuff? – Jon Lin Aug 18 '12 at 17:28
  • Oh~ the /admin/123 is a example, actually I am trying to find some situation for practice. – Azure Chen Aug 18 '12 at 17:52
  • I think maybe I can make the /index/admin/123 redirect to /web/index.php with "admin" and "123" two variable. So, I have to match the "index" string first. – Azure Chen Aug 18 '12 at 17:54

1 Answers1

0

RewriteRule ^/index/?([A-Za-z0-9-/]*)$ /web/index.php?page=$1 [QSA,L]

insert (.php)? if you also want to match a plain /index.php too.

Dirk-Willem van Gulik
  • 7,566
  • 2
  • 35
  • 40