【问题标题】:Rewriting url on htacess file not working [duplicate]重写htaccess文件中的url不起作用[重复]
【发布时间】:2018-09-21 05:22:28
【问题描述】:

使用.htacess重写规则,我想转换这个链接:

http://localhost/CodeArk/?page=mypage

进入

http://localhost/CodeArk/mypage

这是我当前在 .htaccess 文件中的代码,但它不起作用

Options +FollowSymLinks
RewriteEngine On
RewriteRule    ^mypage/?$  http://localhost/CodeArk/?page=mypage    [NC,L] 

而且这也不是动态的,有没有办法让它工作并使其动态?

【问题讨论】:

标签: php url-rewriting


【解决方案1】:
Options +FollowSymlinks 
RewriteEngine On
RewriteRule ^/?page=(.*)$ /$1 [R=301,NC,L] //use this

或者你也可以使用

RewriteRule ^/CodeArk/?page=(.*)$ /CodeArk/$1 [R=301,NC,L]

【讨论】:

    猜你喜欢
    • 2015-04-15
    • 2015-02-03
    • 2014-08-08
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多