Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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
生成器URL友好的SEO PHP with.htaccess_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

生成器URL友好的SEO PHP with.htaccess

生成器URL友好的SEO PHP with.htaccess,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,所以我想创建一个带有隐藏变量的URL友好型,如下所示: website.dev/en/page/detail.html(工作,显示内容) .htaccess文件 Options +FollowSymLinks -MultiViews RewriteEngine on RewriteBase / RewriteRule ^([^/]+)/([^/]+)/([^/]+)/(.*)$ index.php?lang=$1&page=$2&detail=$3 [L,QSA,NC] R

所以我想创建一个带有隐藏变量的URL友好型,如下所示:

website.dev/en/page/detail.html(工作,显示内容)

.htaccess文件

Options +FollowSymLinks -MultiViews


RewriteEngine on
RewriteBase /

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/(.*)$ index.php?lang=$1&page=$2&detail=$3 [L,QSA,NC]
RewriteRule ^([^/]+)/([^/]+)/(.*)$ index.php?lang=$1&page=$2 [L,QSA,NC]
RewriteRule ^([^/]+)/(.*)$ index.php?lang=$1 [L,QSA,NC] 
php文件:

$_GET['lang']); // en
$_GET['page']); // page
$_GET['detail']); // detail.html
因此,页面返回错误状态500,但显示内容

如何解决此问题?

您可以使用:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/(.+)$ index.php?lang=$1&page=$2&detail=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/(.+)$ index.php?lang=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/(.+)$ index.php?lang=$1 [L,QSA]

不起作用:(根据该规则,文件夹before don't work to检查您的error.log并粘贴针对500错误的准确错误日志。这意味着您没有查看正确的文件。Apache error.logi中记录了每500个错误。我已经找到了日志文件,并且该类型的错误为空。但是当将PHP 5.6更改为PHP 5.5.24时,问题就迎刃而解了,但为什么会发生这种情况n新版本的PHP你有什么想法吗?非常感谢:)你的版本更好,但只适用于长URL,我的适用于拆分URL