Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess问题-未重写url_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php htaccess问题-未重写url

Php htaccess问题-未重写url,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我知道这个问题以前被问过很多次,但我需要帮助。我花了好几个小时在这上面,我不知道下面的htaccess代码到底出了什么问题 Options +FollowSymLinks RewriteEngine on RewriteRule services/z/(.*)/ services.php?z=$1 RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://rcunlocks.com/$1 [R,L] 我正在尝试重新编写url ht

我知道这个问题以前被问过很多次,但我需要帮助。我花了好几个小时在这上面,我不知道下面的
htaccess
代码到底出了什么问题

Options +FollowSymLinks

RewriteEngine on

RewriteRule services/z/(.*)/ services.php?z=$1

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://rcunlocks.com/$1 [R,L]
我正在尝试重新编写url

https://rcunlocks.com/services.php?z=spus3

https://rcunlocks.com/services/spus3

如果我的htaccess文件有任何问题,请告诉我

非常感谢你的帮助。谢谢。

试试这个

Options +FollowSymlinks
RewriteEngine on
# check that the request url is neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^services/(.*) services.php?z=$1 [NC]
试试这个

Options +FollowSymlinks
RewriteEngine on
# check that the request url is neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^services/(.*) services.php?z=$1 [NC]
我看到两个问题:

  • 重写后的重定向规则可以向浏览器公开您的内部URI
    /services.php?z=spus3
  • 选项
    MultiViews
    可以覆盖此重写规则
  • 要解决这两个问题,请使用以下方法:

    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=302,L]
    
    RewriteRule ^services/z/([^/]+)/?$ services.php?z=$1 [L,QSA,NC]
    
    我看到两个问题:

  • 重写后的重定向规则可以向浏览器公开您的内部URI
    /services.php?z=spus3
  • 选项
    MultiViews
    可以覆盖此重写规则
  • 要解决这两个问题,请使用以下方法:

    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=302,L]
    
    RewriteRule ^services/z/([^/]+)/?$ services.php?z=$1 [L,QSA,NC]
    

    我猜你必须在你的规则后添加
    [NC,L]
    ,因为最后一条规则会将所有内容重写回默认结构。我猜你必须在规则后添加
    [NC,L]
    ,因为最后一条规则会将所有内容重写回默认结构。我尝试了,但仍然没有成功。我想我会阻止它,让它转到下一个重写规则。。我说的对吗?输入
    https://rcunlocks.com/services/spus3
    URL在浏览器中?我得到了一个多选页面-状态300好吧,这意味着超出了这些规则,因为我的所有规则都没有返回状态=300。我试过了,仍然没有成功。我想我会阻止它,让它转到下一个重写规则。。我说的对吗?输入
    https://rcunlocks.com/services/spus3
    URL在浏览器中?我得到了一个多选页面-状态300,这意味着超出了这些规则,因为我的所有规则都没有返回状态=300