doxrxwn2252
doxrxwn2252
2015-01-08 08:32

.htaccess文件无法在服务器上运行

已采纳

I have a URL like this

www.subdomain.mydomain.com/mydir/admin/index.php?page=dashboard

I want to have a user friendly url like this

www.subdomain.mydomain.com/mydir/admin/dashboard

How do I achieve this? I am trying with the below mentioned code. What am I doing wrong here?

Options -MultiViews

# URL rewriting module activation
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule .* - [F]
RewriteBase /
Options +FollowSymLinks


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

For a similar context please refer this question.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douao8353 douao8353 6年前

    Try this .htaccess:

    Options +FollowSymLinks -MultiViews   
    RewriteEngine on
    
    # use appropriate rewrite base
    RewriteBase /mydir/admin/
    
    RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
    RewriteRule ^ - [F]
    
    RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+) [NC]
    RewriteRule ^ %1?  [L,R]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]
    
    点赞 评论 复制链接分享