让我们说我的网站结构是这样的:
www.mywebsite.com/directory/$variabledirectoryname/$variableproductlink
正如你在中间看到的,我在url中有2个变量,但最后一个是poduct链接。我的index.php文件保留在www.mywebsite.com/directory/$variabledirectoryname文件夹中。如何加载? 我有这段代码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php [L]
但它不起作用..谢谢!
答案 0 :(得分:2)
您可以在/directory/.htaccess
:
RewriteEngine On
RewriteBase /directory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/[^/]+/?$ $1/index.php [L]
<强>更新强>
您可以在 root .htaccess
中使用此规则:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(directory/[^/]+)/[^/]+/?$ $1/index.php [L]