我想重写我当前的目录结构,以创建一个友好的URL。
目录结构
根文件夹
- 包括
- 图像
- css
- js
- 部分
- 页码
- 第1页
- index.php
- 第2页
- 第3页
- 第4页
因此,当前的URL路径是www.example.com/page/page1,但我想要的是www.example.com/spage1。因此,网站可以放置Bitbucket以启用版本控制。
我们非常感谢任何帮助或链接。
感谢
您可以在root/.htaccess
:中使用以下规则
RewriteEngine on
#1) Redirect from "/page/foobar" to "/foobar" #
RewriteCond %{THE_REQUEST} /pages/(.+)'sHTTP [NC]
RewriteRule ^ /%1 [L,R]
#2)internally redirect "/foobar" to "/page/foobar" #
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /pages/$1 [NC,L]
这将在内部将/page
重定向到/page/page
。