这是我的.htaccess文件的内容。
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online-products$ products.php?type=online
RewriteRule ^land-products$ products.php?type=land
RewriteRule ^payment-methods$ payment-methods.php
RewriteRule ^withdrawal-methods$ withdrawal-methods.php
RewriteRule ^deposit-methods$ deposit-methods.php
RewriteRule ^product-bonuses$ product-bonuses.php
RewriteRule ^law-and-regulations$ law-and-regulations.php
RewriteRule ^product-news$ product-news.php
RewriteRule ^product-games$ product-games.php
RewriteRule ^no-products$ no-products.php
RewriteRule ^page-not-found$ notfound.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^casinos/(.*)$ product.php?id=$1
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ cms.php?link=$1
ErrorDocument 404 /notfound.php
我在这里想要实现的是,第一组规则适用于某些特定的关键字,这些关键字应该重定向到特定的硬编码页面。但是,您可以看到来自这些关键字的任何其他parat应该重定向到cms.php作为参数。
但问题是每个关键字都被重定向到cms.php。虽然我想要除了已经硬编码的任何其他关键字.htaccess文件应该去cms.php。不只是每个关键字。
示例:
www.sitename.com/online-products -> www.sitename.com/products.php?type=online
www.sitename.com/about-the-website -> www.sitename.com/cms.php?id=about-the-website
www.sitename.com/product-news -> www.sitename.com/product-news.php
我面临的另一个问题是我不能在空格中使用任何关键字。像“在线产品”一样好,但我不能使用“在线产品”。
请用你的专业知识帮助我。非常感谢您的帮助。欣赏它。
答案 0 :(得分:0)
您可以通过在规则末尾添加[L]来解决第一部分,例如:
RewriteRule ^page-not-found$ notfound.php [L]
这应该可以防止任何后续规则被运行。请参阅:http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
如果您的网址中必须有空格,您应该可以这样做:
RewriteRule ^online\sproducts$ products.php?type=online [L]
答案 1 :(得分:0)
以下是更新后的代码:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online\scasinos$ casinos.php?type=online
RewriteRule ^land-casinos$ casinos.php?type=land
RewriteRule ^payment-methods$ payment-methods.php
RewriteRule ^withdrawal-methods$ withdrawal-methods.php
RewriteRule ^deposit-methods$ deposit-methods.php
RewriteRule ^casino-bonuses$ casino-bonuses.php
RewriteRule ^law-and-regulations$ law-and-regulations.php
RewriteRule ^casino-news$ casino-news.php
RewriteRule ^casino-games$ casino-games.php
RewriteRule ^no-deposit-casinos$ no-deposit-casinos.php [L]
RewriteRule ^page-not-found$ notfound.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^casinos/(.*)$ casino.php?id=$1
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ cms.php?link=$1
ErrorDocument 404 /notfound.php