有人能给我一个特定的.htaccess的代码吗?

有人能给我一个特定的.htaccess的代码吗?,.htaccess,.htaccess,我试着用一些东西制作自己的.htaccess文件,但我对它不是很熟悉。我在谷歌上搜索了很多次,但最后还是把事情搞砸了。 那么,有人能给我一个工作的.htaccess代码片段吗? 我希望它执行以下操作: 从非www重定向到www 将index.php重定向到/在所有目录中 从所有目录中的所有文件中删除“.php” 将URL重定向到product.php?detail=Phone到product/detail/Phone (同时管理尾部斜杠问题) 希望有人能帮忙 Options +FollowSym

我试着用一些东西制作自己的.htaccess文件,但我对它不是很熟悉。我在谷歌上搜索了很多次,但最后还是把事情搞砸了。 那么,有人能给我一个工作的.htaccess代码片段吗? 我希望它执行以下操作:

  • 从非www重定向到www
  • 将index.php重定向到/在所有目录中
  • 从所有目录中的所有文件中删除“.php”
  • 将URL重定向到product.php?detail=Phone到product/detail/Phone (同时管理尾部斜杠问题)
  • 希望有人能帮忙

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteBase /
    
    #non-www to www
    RewriteCond %{HTTP_HOST} ^nevca.getfreehosting.co.uk [NC] 
    RewriteRule ^(.*)$ http://example.co.uk/$1 [R=301,L] 
    
    # index.php to /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(([^/]+/)*[^.]+)index\.php$ /$1 [R=301,L]
    
    
    #index/menu/123/ to index.php?menu=123
    RewriteRule ^index/([^/]+)/?$ /index.php?menu=$1 [L]
    
    #index.php?menu=123 to index/menu/123/
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index2\.php\?menu=([^&]+)\ HTTP/
    RewriteRule ^index\.php$ http://example.co.uk/index/%1/? [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^/]+)/$ $1.php
    
    # Forces a trailing slash to be added
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]
    
    像这样的,只是最后两条规则不起作用。。。
    我还希望只有当请求与“.php?”不同时才删除.php?…”

    html5样板文件htaccess中有这些东西,您应该看看并使用您想要的部分:

    看看这个