问题描述
|
这是我关于htaccess的第三个问题。我应该单身。但是我认为这是一个太大的问题。
这用于我自己的CMS。 :o)
我的htaccess是:
RewriteEngine on
RewriteRule ^page/([^/\\.]+)/?$ index.PHP?page=$1 [L]
Remove index.PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /.*index\\.PHP\\ HTTP/
RewriteRule ^(.*)index\\.PHP$ /$1 [R=301,L]
我想做的是:
从我的网址中删除/ page /,例如:myurl.com/home
现在,我的网址是:www.myurl.com/page/home或提供的任何标题。现在,当人们在CMS中创建新页面时,他们可能不需要一个名为:关于我们的页面。
这将是:
www.myurl.com/page/about%20us
如何添加\“-\”而不是%20?
解决方法
您可以轻松地从.htaccess中删除“ 1”,但是您必须忽略现有的文件和目录:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\\.]+)/?$ index.php?page=$1 [L]
您的第二个问题与.htaccess无关。您必须将页面About us
链接为/about-us/
而不是/about%20us/
(%20
表示空格),如果调用页面/about-us/
(index.php?page=about-us
),只需将其处理为/about%20us/
即可。因此,只需将空格替换为-
。