Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache htaccessurl重写。I';我陷入了困境_Apache_.htaccess_Url_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache htaccessurl重写。I';我陷入了困境

Apache htaccessurl重写。I';我陷入了困境,apache,.htaccess,url,mod-rewrite,url-rewriting,Apache,.htaccess,Url,Mod Rewrite,Url Rewriting,这个问题被问了太多次,但我不知道我做错了什么。 我想说的是,我对htaccess和mod_重写还不熟悉 我有这一页http://localhost/product.php?c=category&p=product 我想重写一下http://localhost/category/product. 试图改变统治者的顺序,但其他统治者不再有效 访问代码: # rewrite search page RewriteRule ^q-([^/]+)/page-(.*)/?$ search.php?q=$1&

这个问题被问了太多次,但我不知道我做错了什么。 我想说的是,我对htaccess和mod_重写还不熟悉

我有这一页http://localhost/product.php?c=category&p=product 我想重写一下http://localhost/category/product.

试图改变统治者的顺序,但其他统治者不再有效

访问代码:

# rewrite search page
RewriteRule ^q-([^/]+)/page-(.*)/?$ search.php?q=$1&page=$2 [NC,L]

RewriteRule ^q-([^/]+)/?$ search.php?q=$1 [NC,L]
RewriteRule ^q/?$ search.php?q [NC,L]
RewriteRule cautare(/)? cautare.php [NC,L]

RewriteRule ^multisearch/?$ multisearch.php [NC,L]

# rewrite /category to /index.php?c=category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#----------------Old version----------------------#
RewriteRule ^([^/]+)/?$ /index.php/?c=$1 [L,QSA]


# rewrite /category to /index.php?t=tab
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^t/([^/]+)/?$ /index.php/?t=$1 [L,QSA]
RewriteRule ^t/([^/]+)/([^-]+.+)/?$ /index.php/$2?t=$1 [L,QSA]


# rewrite /category/brand-mybrand/country-mycountry/offer-yes/new-yes
# to /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#----------------Old version----------------------#
RewriteRule ^([^/]+)/([^-]+.+)/?$ /index.php/$2?c=$1 [L,QSA]


# rewrite /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
# converts any /name-val/ to query parameter name=val in every rewrite
# stopping when there is no part left after /index.php
RewriteRule ^(index\.php)/([^-]+)-([^/]+)(/.*)?$ /$1$4?$2=$3 [L,QSA]

# rewrite product page
RewriteRule ^([A-Za-z0-9_?-]+)/([A-Za-z0-9_?-]+)(/)?$ product.php?c=$1&p=$2 [L,QSA]
事实上,如果我点击产品页面,什么都不会发生(只是刷新)


对不起,我说的是英语。

您的.htaccess似乎过于复杂。我试图将其简化一点:

# rewrite search page
RewriteRule ^q-([^/]+)/page-(.*)/?$ search.php?q=$1&page=$2 [NC,L,QSA]
RewriteRule ^q-([^/]+)/?$ search.php?q=$1 [NC,L,QSA]
RewriteRule ^q/?$ search.php?q [NC,L,QSA]

RewriteRule ^(cautare|multisearch)/?$ $1.php [NC,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# rewrite /category to /index.php?t=tab
RewriteRule ^t/([^/]+)/?$ index.php/?t=$1 [L,QSA,NC]
RewriteRule ^t/([^/]+)/([^-]+.+)/?$ index.php/$2?t=$1 [L,QSA,NC]

# rewrite /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
# converts any /name-val/ to query parameter name=val in every rewrite
# stopping when there is no part left after /index.php
RewriteRule ^(index\.php)/([^-]+)-([^/]+)(/.*)?$ /$1$4?$2=$3 [L,QSA,NC]

# rewrite /category/brand-mybrand/country-mycountry/offer-yes/new-yes
# to /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
RewriteRule ^([^/]+)/([^-]+-.+)/?$ index.php/$2?c=$1 [L,QSA]

# rewrite product page
RewriteRule ^([\w-]+)/([\w-]+)/?$ product.php?c=$1&p=$2 [L,QSA]

# rewrite /category to /index.php?c=category
RewriteRule ^([^/]+)/?$ index.php/?c=$1 [L,QSA]

在Chrome开发工具中测试,禁用缓存,并在网络选项卡中签入301/302/404 URL。所有URL都是200。它将我重定向到,但结果来自感谢您的回答。它是有效的,除了RewriteRule^(index\.php)/([^-]+)-([^/]+)(/.*)?$/$1$4?$2=$3[L,QSA,NC]获得一个类似于404的品牌-是对您时间的一种过滤感谢。