我想将我网站的动态网址更改为静态网址以获得更好的搜索引擎优化。我尝试了很多组合,但其中任何一个都没有用。
我的网址是index.php?page=something
,我想将其转换为page/something
我尝试过如下组合
RewriteEngine On
RewriteRule ^page/([0-9a-z_-]+)$ index.php?page=$1 [NC,L]
或者
RewriteEngine On
RewriteRule ^page/(.*)$ index.php?page=$1 [NC,L]
当我在浏览器中输入mydomain / page /时,某些内容会返回给我带有导航栏和页脚的页面,但没有任何内容。
更新 这就是问题所在:PHP problems with current url
答案 0 :(得分:1)
RewriteEngine On
#if the requested url isn't a file or a dir or an image
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.gif|\.jpg|\.png)$ [NC]
#process index.php
RewriteRule ^([^/]+)/page/?$ /index.php?page=$1 [L,QSA,NC]