Php 如何重写我的URLhttp://www.ritascantina.com/latestnews/index/18 到http://www.ritascantina.com/latestnews/18
我想重新写入我的URL 现有url为:Php 如何重写我的URLhttp://www.ritascantina.com/latestnews/index/18 到http://www.ritascantina.com/latestnews/18,php,html,Php,Html,我想重新写入我的URL 现有url为:http://www.ritascantina.com/latestnews/index/18 我想要这样:http://www.ritascantina.com/latestnews/18 我的HTACCESS文件是: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^(home(/index)?|index(\.php)?)/?$
http://www.ritascantina.com/latestnews/index/18
我想要这样:http://www.ritascantina.com/latestnews/18
我的HTACCESS文件是:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写基/
重写规则^(home(/index)| index(\.php)/?$/[L,R=301]
重写规则^(.*)/索引/?$$1[L,R=301]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
ErrorDocument 404/index.php
有什么建议吗?看起来你没有匹配结尾的数字,所以规则没有被使用。尝试更改:
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
致:
通过这种方式,您还可以获得末尾的数字使用以下方法:
RewriteRule ^latestnews/([0-9]+)/?$ latestnews/index/$1
请参阅。尝试访问该页面时,您得到了什么?
RewriteRule ^latestnews/([0-9]+)/?$ latestnews/index/$1