Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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
Regex 无法使用htaccess创建seo友好url_Regex_Apache_.htaccess_Mod Rewrite_Clean Urls - Fatal编程技术网

Regex 无法使用htaccess创建seo友好url

Regex 无法使用htaccess创建seo友好url,regex,apache,.htaccess,mod-rewrite,clean-urls,Regex,Apache,.htaccess,Mod Rewrite,Clean Urls,我正试图使友好的网址,所有的网址都工作绝对好,只有一个网址不工作。我想要 http://example.com/checkout/cart 从中显示页面的步骤 http://example.com/index.php?route=checkout/cart 我尝试了很多解决方案,但都不管用 Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCon

我正试图使友好的网址,所有的网址都工作绝对好,只有一个网址不工作。我想要

http://example.com/checkout/cart 
从中显示页面的步骤

http://example.com/index.php?route=checkout/cart
我尝试了很多解决方案,但都不管用

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^checkout/cart /index.php?route=checkout/cart [L]
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
请帮忙,提前谢谢


在尝试了大量代码之后,最新的Htacces文件包含以下代码

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteRule ^(.*)/cart/? /index.php?route=checkout/checkout [L]
RewriteRule ^cart/? /index.php?route=checkout/cart [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Options+FollowSymlinks
#防止Directoy上市
选项-索引
#阻止直接访问文件
命令拒绝,允许
全盘否定
#搜索引擎优化URL设置
重新启动发动机
#如果您的opencart安装没有在主web文件夹上运行,请确保您的文件夹在ie./beans/shop中运行/
重写基/
重写规则^sitemap.xml$index.php?route=feed/google_sitemap[L]
重写规则^googlebase.xml$index.php?route=feed/google_base[L]
重写规则^download/(.*)/index.php?route=error/not_found[L]
重写规则^(.*)/cart//index.php?route=checkout/checkout[L]
重写规则^cart//index.php?route=checkout/cart[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写条件%{REQUEST\u URI}!。*\。(ico | gif | jpg | jpeg | png | js | css)
RewriteRule^([^?]*)index.php?_route_uu=$1[L,QSA]
子目录中没有htaccess文件,签出文件夹中也没有


谢谢:)

您可能只需要一条规则。请注意,
RewriteCond
仅适用于紧跟其后的
RewriteRule
,因此您拥有的第二条规则没有任何条件

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?route=$1 [L,QSA]

您的.htaccess如下所示:

Options +FollowSymlinks -MultiViews

# Prevent Directoy listing
#Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /

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

RewriteRule ^sitemap\.xml$ index.php?route=feed/google_sitemap [L,QSA,NC]
RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L,QSA,NC]
RewriteRule ^download/(.*)$ /index.php?route=error/not_found [L,QSA,NC]
RewriteRule ^checkout/cart/? /index.php?route=checkout/cart [L,QSA,NC]

RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^/]+)/?$ index.php?_route_=$1 [L,QSA]
Options+FollowSymlinks-多视图
#防止Directoy上市
#选项-索引
#阻止直接访问文件
命令拒绝,允许
全盘否定
#搜索引擎优化URL设置
重新启动发动机
#如果您的opencart安装没有在主web文件夹上运行,请确保您的文件夹在ie./beans/shop中运行/
重写基/
RewriteCond%{REQUEST_FILENAME}-f[或]
RewriteCond%{REQUEST_FILENAME}-d
重写规则^-[L]
重写规则^sitemap\.xml$index.php?route=feed/google_sitemap[L,QSA,NC]
重写规则^googlebase\.xml$index.php?route=feed/google_base[L,QSA,NC]
重写规则^download/(.*)$/index.php?路由=错误/未找到[L,QSA,NC]
是否重写规则^checkout/cart//php?route=checkout/cart[L,QSA,NC]
重写条件%{REQUEST\u URI}!。*\。(ico | gif | jpg | jpeg | png | js | css)
重写规则^([^/]+)/?$index.php?\u路由=$1[L,QSA]

最初将其解读为“性友好url”。。。这可能比这个问题更能说明我。。。但是由于SEO和URL是缩写,它们可能应该大写。当你访问
http://example.com/checkout/cart
在浏览器中?@anubhava它给我404未找到错误,当我访问它时,它会显示正确的页面是
/checkout/
目录?@anubhava是,它是保存名为cart的文件的目录。我最近在重写条件之前又尝试了两条规则--
RewriteRule^(.*)/cart//index.php?route=checkout/cart[L]重写规则^cart//index.php?route=checkout/cart[L]导致到达目的地时url不正确
()`rest所有url都出现404错误感谢回复,主页出现404未找到错误我使用htaccess访问了更多url,它们工作正常,我向您展示完整的代码
RewriteBase/RewriteRule^sitemap.xml$index.php?route=feed/google_sitemap[L]RewriteRule^googlebase.xml$index.php?route=feed/google_base[L]RewriteRule^download/(.*)/index.php?route=error/not_found[L]RewriteCond%{REQUEST\u FILENAME}-f RewriteCond%{REQUEST_FILENAME}-已重写条件%{REQUEST\u URI}!。*\。(ico | gif | jpg | jpeg | png | js | css)RewriteRule^([^?]*)index.php?(u route)=$1[L,QSA]