友好的URL和锚点

时间:2015-11-16 12:26:08

标签: html .htaccess anchor

我试图实现文档转到使用友好URL提供的锚名称。

RewriteRule ^files/page/([a-zA-Z0-9\-]+)?$ myPage.html#$1

但这不起作用。

我尝试使用页面插入网址:myPage.html#myAnchor并且工作正常。所以问题必须在htaccess行中。

我搜索并找到了this旧问题的答案似乎有效,但遗憾的是不适合我。

HTACCESS文件(用[L]标志更新):

AddType text/x-component .htc

RewriteEngine on
RewriteBase /

RewriteRule ^ahorro/?$ ahorro-para-mi-futuro.html [L]
RewriteRule ^ahorro/como-es-nuestro-ahorro/([a-zA-Z0-9\-]+)?/?$ como-es-nuestro-ahorro.html#$1 [L]
RewriteRule ^ahorro/preparado-para-tu-jubilacion/?$ hasta-que-punto-estas-preparado-para-tu-jubilacion.html [L]
RewriteRule ^ahorro/ventajas-fiscales/?$ ventajas-fiscales.html [L]
RewriteRule ^ahorro/para-mi-futuro/([a-zA-Z0-9\-]+)?/?$ por-que-deberia-ahorrar-para-mi-futuro.html#$1 [NE,NC,L]

RewriteRule ^preparar-jubilacion/?$ preparo-mi-jubilacion.html [L]
RewriteRule ^preparar-jubilacion/calcula-tu-patrimonio/?$ calcula-tu-patrimonio.html [L]
RewriteRule ^preparar-jubilacion/calculadora-gastos/?$ calculadora-de-gastos.html [L]
RewriteRule ^preparar-jubilacion/disponibilidad-de-ahorros/?$ como-podre-disponer-de-mis-ahorros.html [L]
RewriteRule ^preparar-jubilacion/4-pasos-para-mi-jubilacion/?$ 4-pasos-para-planificar-tu-jubilacion.html [L]

RewriteRule ^vivir-jubilacion/?$ vivo-mi-jubilacion.html [L]
RewriteRule ^vivir-jubilacion/prioridades/?$ que-necesito-y-cuales-son-mis-prioridades.html [L]
RewriteRule ^vivir-jubilacion/disponer-de-mis-ahorros/?$ como-podre-disponer-de-mis-ahorros.html [L]
RewriteRule ^vivir-jubilacion/4-pasos-para-mi-jubilacion/?$ 4-pasos-para-planificar-tu-jubilacion.html [L]

RewriteRule ^encuentros/?$ encuentros-futuros.html [L]

RewriteRule ^calculadoras-y-simuladores/calculadora-ahorro/?$ calculadora-de-ahorro.html [L]
RewriteRule ^calculadoras-y-simuladores/calculadora-gastos/?$ calculadora-de-gastos.html [L]
RewriteRule ^calculadoras-y-simuladores/calcula-tu-patrimonio/?$ calcula-tu-patrimonio.html [L]

RewriteRule ^politica-cookies/?$ politica_cookies.html [L]

2 个答案:

答案 0 :(得分:0)

尝试NE(No Escape)标志

Sm Shopby index process unknown error:
exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '`main_table`.`frontend_input`' in 'where clause'' in /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /var/www/vhosts/domain/sub-domain/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /var/www/vhosts/domain/sub-domain/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
#5 /var/www/vhosts/domain/sub-domain/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
#6 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
#7 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection/Db.php(740): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
#8 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
#9 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection/Db.php(572): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#10 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection.php(741): Varien_Data_Collection_Db->load()
#11 /var/www/vhosts/domain/sub-domain/app/code/local/Sm/Shopby/Model/Resource/Indexer/Attribute.php(29): Varien_Data_Collection->getIterator()
#12 /var/www/vhosts/domain/sub-domain/app/code/local/Sm/Shopby/Model/Resource/Indexer/Attribute.php(20): Sm_Shopby_Model_Resource_Indexer_Attribute->reindexSeoUrlKeys()
#13 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Sm_Shopby_Model_Resource_Indexer_Attribute->reindexAll()
#14 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#15 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#16 /var/www/vhosts/domain/sub-domain/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#17 /var/www/vhosts/domain/sub-domain/shell/indexer.php(216): Mage_Shell_Compiler->run()
#18 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '`main_table`.`frontend_input`' in 'where clause', query was: SELECT `main_table`.*, `additional_table`.* FROM `eav_attribute` AS `main_table`
 INNER JOIN `catalog_eav_attribute` AS `additional_table` ON additional_table.attribute_id = main_table.attribute_id WHERE (`main_table`.`entity_type_id` = '4') AND (```main_table```.```frontend_input``` IN('select', 'multiselect'))' in /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /var/www/vhosts/domain/sub-domain/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/vhosts/domain/sub-domain/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
#4 /var/www/vhosts/domain/sub-domain/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
#5 /var/www/vhosts/domain/sub-domain/lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
#6 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection/Db.php(740): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
#7 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
#8 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection/Db.php(572): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#9 /var/www/vhosts/domain/sub-domain/lib/Varien/Data/Collection.php(741): Varien_Data_Collection_Db->load()
#10 /var/www/vhosts/domain/sub-domain/app/code/local/Sm/Shopby/Model/Resource/Indexer/Attribute.php(29): Varien_Data_Collection->getIterator()
#11 /var/www/vhosts/domain/sub-domain/app/code/local/Sm/Shopby/Model/Resource/Indexer/Attribute.php(20): Sm_Shopby_Model_Resource_Indexer_Attribute->reindexSeoUrlKeys()
#12 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Sm_Shopby_Model_Resource_Indexer_Attribute->reindexAll()
#13 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#14 /var/www/vhosts/domain/sub-domain/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#15 /var/www/vhosts/domain/sub-domain/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#16 /var/www/vhosts/domain/sub-domain/shell/indexer.php(216): Mage_Shell_Compiler->run()
#17 {main}

来源:

Apache重写标记:https://httpd.apache.org/docs/2.4/rewrite/flags.html

答案 1 :(得分:0)

我想我知道它发生了什么,史诗般的facepalm

#它正在评论它之后的所有内容,因此,它无法正常工作。解决方法,在REGEX中添加#

RewriteRule ^ahorro/para-mi-futuro/?(\#[a-zA-Z0-9\-]+)?/?$ por-que-deberia-ahorrar-para-mi-futuro.html$1 [NE,NC,L]
相关问题