.htaccess 用于重写影响 web-dev 文件夹的 url

发布于 2024-10-09 07:33:25 字数 2455 浏览 0 评论 0原文

好的,有两个问题,

首先,我是 htaccess 的新手,并且有很多问题弄清楚如何为 google SEO 制作良好的重写 URL,所以我做了这个:

Options +FollowSymlinks
RewriteEngine on

### [... other language ...]


### English product URL

# Product page : (url/en/products/items-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)\.html$   produits.php?lang=$1&art=$2 [L,NC]

# List of categories of a division (url/en/products/items-1-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)\.html$   produits.php?lang=$1&idc=$2&catd=$3 [L,NC]

# List of subcategories of a categorie (url/en/products/items-1-1-1.html) 
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)-([0-9]+)\.html$   produits.php?lang=$1&idc=$2&catd=$3&catt=$4 [L,NC]

# List of sub-sub-categories of a sub-categorie (url/en/products/items-1-1-1-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ produits.php?lang=$1&idc=$2&catd=$3&catt=$4&catq=$5 [L,NC]

### Mod Rewrite to make url more friendly EN
RewriteRule ^([a-z]+)/[B-b]ecome-a-[C-c]lient client.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[C-c]ontact-[U-u]s contact.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[O-o]ops erreur.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[I-i]ndustrial-[D-d]ivision industriel.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[C-c]art panier.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[S-s]earch recherche.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[H-h]ealt-[D-d]ivision sanitaire.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[H-h]ome index.php?lang=$1 [L,NC]

### Compression Mod
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/php
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

## [... errors page ...]

现在的问题是,如果我能达到一些发展目标目的我不能这样做

示例:我将整个网站复制到域根目录中名为 work 的文件夹中,因此 url 将是

www.website-url.com/work

此时一切都很好我可以访问这部分,但是如果我要访问 products.php 我就可以做到...我知道我无法通过像 www.website-url.com/work/products/items-1.html 这样的重写来达到它,但我应该可以直接访问吗?

我的第二个问题是,我会在我的服务器上使用压缩,以使客户端的网站加载速度更快,因为我有很多 javascipt 与 jQuery 一起工作。但我无法让它工作,我已经检查过在线工具,但从未通过压缩测试。

感谢您的帮助 !

Okay there is 2 questions,

First, I'm new with htaccess and have a lot of problem figure out how to make good Rewrited URL for google SEO so i've made this :

Options +FollowSymlinks
RewriteEngine on

### [... other language ...]


### English product URL

# Product page : (url/en/products/items-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)\.html$   produits.php?lang=$1&art=$2 [L,NC]

# List of categories of a division (url/en/products/items-1-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)\.html$   produits.php?lang=$1&idc=$2&catd=$3 [L,NC]

# List of subcategories of a categorie (url/en/products/items-1-1-1.html) 
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)-([0-9]+)\.html$   produits.php?lang=$1&idc=$2&catd=$3&catt=$4 [L,NC]

# List of sub-sub-categories of a sub-categorie (url/en/products/items-1-1-1-1.html)
RewriteRule ^([a-z]+)/[P-p]roducts/item-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ produits.php?lang=$1&idc=$2&catd=$3&catt=$4&catq=$5 [L,NC]

### Mod Rewrite to make url more friendly EN
RewriteRule ^([a-z]+)/[B-b]ecome-a-[C-c]lient client.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[C-c]ontact-[U-u]s contact.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[O-o]ops erreur.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[I-i]ndustrial-[D-d]ivision industriel.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[C-c]art panier.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[S-s]earch recherche.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[H-h]ealt-[D-d]ivision sanitaire.php?lang=$1 [L,NC]
RewriteRule ^([a-z]+)/[H-h]ome index.php?lang=$1 [L,NC]

### Compression Mod
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/php
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

## [... errors page ...]

The problem now is that if I would reach something for developpement purpose I can't do it

Exemple : I copy the whole website into a folder named work a the root of the domain so the url would be

www.website-url.com/work

at this point everything is fine I can access this part, but if I would access products.php I just can do it... I know that I can't reach it with the rewrite like www.website-url.com/work/products/items-1.html but I should be able to access it directly no ?

My second questions is that I would use compression for my server to make the website load more faster for client because I have a lot of javascipt working with jQuery a lot. But I can't make it work, I've checked with online tools and never pass compression test.

Thanks for your help !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文