dsadsa123111 2016-04-20 18:24
浏览 64
已采纳

HTACCESS REWRITE无法正常工作

My current URL looks something like this

"portfolio/index.php?page=work"

I have written a rewrite rule in my .htaccess file to then swap this out so that the URL ends up looking like

"portfolio/work"

# ######################################################################
# # URL REWRITE                                                       #
# ######################################################################

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1

This is put at the top of my .htaccess page and I am using the HTML5 Boilerplate .htacccess file https://html5boilerplate.com/

Is there something that I am missing?

EDIT:

Added a pastebin of the full .htaccess file. The code is right at the top, and is slightly different than the original question as I was playing around to try get it working.

http://pastebin.com/63CJ67MJ

  • 写回答

2条回答 默认 最新

  • doumaqing6652 2016-04-20 18:57
    关注

    It looks like the rule is conflicting with other rules in your htaccess as your rule do not have a Last [L] flag at the end, try :

    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?page=$1 [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!