简体   繁体   English

.htaccess文件没有重定向 - 指导通缉

[英].htaccess file not redirecting - guidance wanted

I have this url: 我有这个网址:

<a href="drive_to_london/?procid=12">details</a>

the url becomes in addressbar: 网址变为地址栏:

http://web228.sydney.webhoster.ag/soputnik/drive_to_london/?procid=12

but I want to process the logic in details.php . 但我想在details.php处理逻辑。

How can I process the data in details.php in background and keep the first url in the address? 如何在后台处理details.php中的数据并将第一个URL保留在地址中?

I tried this: 我试过这个:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^drive_to_(.*)$   http://web228.sydney.webhoster.ag/soputnik/details.php [R=301,L]

but it is not working, error is: NOT FOUND 但它不工作,错误的是:NOT FOUND

please help 请帮忙

If you don't want the URL to change, then it's not a redirect, just a rewrite. 如果您不想更改URL,那么它不是重定向,只是重写。

Change: 更改:

RewriteRule ^/test/drive_to_(.*)$   /test/details.php [R=301,L]

To something like: 对于这样的事情:

RewriteRule ^/test/drive_to_(.*)$   /test/details.php?city=$1 [L]

Substitute your code with this: 用这个代替你的代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^test/drive_to_(.*?)/?$ /test/details.php [L,NC]
  1. dont forget to pass any url params to details.php. 别忘了将任何url params传递给details.php。

    Rewriterule ^/drive_for_(.*)/\\?(.*)$ http://domain.de/test/details.php/?$1 [R=301,L]

  2. it seems relevant that you want to pass the city name as well, otherwise that context gets lost in the rewrite. 你想要传递城市名称似乎是相关的,否则在重写中上下文会丢失。 If that is another url param you could pass it through to details.php as such 如果这是另一个url参数,你可以将它传递给details.php

    Rewriterule ^/drive_for_(.*)/\\?(.*)$ http://domain.de/test/details.php/?$2&city=$1 [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM