我正在使用Opencart,我也有一些静态页面。 我不想弄乱opencart的SEO选项,那么有没有办法只为特定页面创建干净的URL?
我想要的是:
http://example.com/my-custom-page.php
到
http://example.com/my-custom-page
我正在使用标准的htaccess文件附带opencart包
我有以下几行:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
答案 0 :(得分:0)
如果您想删除网址中的.php扩展名,请使用
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
或者
RewriteEngine on
RewriteRule ^(.*)$ $1.php
如果.html那么你可以做
RewriteRule ^([^\.]+)$ $1.html [NC,L]
答案 1 :(得分:0)
将以下代码放在主目录(root)var func = (function(){
return 'hello';
}());
文件中:
.htaccess
代码将删除my-custom-page.php扩展名,无论其目录是什么,它都是my-custom-page