简体   繁体   English

.htacces重写规则不起作用

[英].htacces rewrite rule not work

I have a website. 我有一个网站。 I want to my site seo friendly. 我想对我的网站进行seo友好。 For that I used .htacces rewrite rule for making custom seo friendly url. 为此,我使用了.htacces重写规则来制作自定义seo友好的url。

I want when I put url ie http://nila.mobi/services it will shows the content of file http://nila.mobi/services.php . 我想在输入网址即http://nila.mobi/services时显示文件http://nila.mobi/services.php的内容。

There have same page structure like that. 有相同的页面结构。 I used the code on .htacces file which I write on bellow. 我使用了在下面编写的.htacces文件上的代码。

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Where am I wrong. 我哪里错了。 Please help me. 请帮我。

Reorder your rules and add L flag: 重新排列规则并添加L标志:

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.+?)/?$ $1.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM