.htaccess 从 URL 中删除子目录
我似乎无法弄清楚这一点,我的根文件夹中有一个目录结构,例如“/state/page--city”。在我的 htaccess 文件中,我将根文件夹中不是目录或文件的所有请求重定向到 page.php。所以我想要的是当用户访问“http://example.com/state/page--city/”时从 URL 中删除“/state”部分,以便 URL 看起来像“http://example” .com/page--city/'。有什么想法吗?谢谢。
.htaccess 文件:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* page.php?&[|]v1||%{REQUEST_URI}[|]v2||-[|]v3||%{HTTP_HOST}[|]v4||%{REQUEST_FILENAME}[|]v5||EOL[~|~]= [QSA,L]
I can't seem to figure this out, I have a directory structure in my root folder like '/state/page--city'. In my htaccess file i redirect all requests that are not directories or files in my root folder to a page.php. So what I would want is to remove the '/state' part from the URL when the users access 'http://example.com/state/page--city/' so that the URL looks like 'http://example.com/page--city/'. Any ideas? Thnx.
.htaccess file:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* page.php?&[|]v1||%{REQUEST_URI}[|]v2||-[|]v3||%{HTTP_HOST}[|]v4||%{REQUEST_FILENAME}[|]v5||EOL[~|~]= [QSA,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论