我的mod_rewrite code htaccess的导致页面不加载 [英] My mod_rewrite code in htaccess caused the page to not load
问题描述
我有可怕的网址是这样的:
I have horrible URLs like this:
的http://example.com/subfolder/index.php?a=1&b=1&token=8d519decbe60db44154b1fbc8c553ac4
我想使它看起来是这样的:
I am trying to make it look like this:
http://example.com/subfolder/menu/1/1/# /
但是,这code导致页面崩溃/找不到什么:
But this code is causing the page to crash/not be found or something:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^a=([0-9]+)&b=([0-9]+)&token=([A-Za-z0-9]+)
RewriteRule ^subfolder/index.php /menu/$1/$2/#? [R=301,L]
我把这个的.htaccess
文件在我的根文件夹 example.com/.htaccess
,我需要把它的子文件夹?
I put this .htaccess
file in my root folder example.com/.htaccess
, do I need to put it in the subfolder?
我收到404找不到网页错误!
I'm getting 404 page not found error !
推荐答案
尝试不同的方法:
RewriteEngine On
RewriteBase /subfolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/([0-9]+)/$ index.php?a=$1&b=$2&token=$3 [L,QSA]
输出:(http://example.com/subfolder/menu/1/1/#/)
<?php
print_r($_GET);
Array
(
[a] => menu
[b] => 1
[token] => 1
)
?>
或 http://example.com/subfolder/menu/1/18d519decbe60db44154b1fbc8c553ac4/#/
RewriteEngine On
RewriteBase /subfolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/([A-Za-z0-9]+)/$ index.php?a=$1&b=$2&token=$3 [L,QSA]
更新:
RewriteEngine On
RewriteBase /subfolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/([0-9]+)/([A-Za-z0-9]+)/$ index.php?a=$2&b=$3&token=$4 [L,QSA]
将匹配: mysite.com/subfolder/menu/1/2/blah123
和传递给的index.php A = 1安培; B = 2及令牌= blah123
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([0-9]+)/([0-9]+)/([A-Za-z0-9]+)/$ index.php?a=$3&b=$4&token=$5 [L,QSA]
将匹配: mysite.com/subfolder/menu/1/2/blah123
和传递给的index.php A = 1安培; B = 2及令牌= blah123
请有这个网站的读取: 的http:// corz .ORG / SERV /花样/ htaccess2.php
这篇关于我的mod_rewrite code htaccess的导致页面不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!