简体   繁体   English

重写.htaccess中的动态网址?

[英]Rewrite dynamic url in .htaccess?

Here is an example url. 这是一个示例网址。 97006 is the query string. 97006是查询字符串。 Customer-Manager is a title that changes for every page. 客户经理是一个标题,每个页面都会更改。 jobdetails.php is run when a button is clicked which brings you to a page like this below. 单击按钮将运行jobdetails.php,这将带您到下面的页面。

http://11.11.111.111/97006/Customer-Manager.html http://11.11.111.111/97006/Customer-Manager.html

I would like the url to be: http://11.11.111.111/job/Customer-Manager.html 我希望该网址为: http : //11.11.111.111/job/Customer-Manager.html

In the .htaccess there is already code for the url I want to change. 在.htaccess中,已经有我要更改的网址代码。

I think this is the condition for the rule: (because its the 1st condition & 1st rule, is thst how it works?) 我认为这是规则的条件:(因为它的第一个条件和第一个规则,它是如何工作的?)

RewriteCond %{QUERY_STRING} base64_encode.*\\(.*\\) [OR]

This is the rule I have tried changing many times but no success: RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\\.html$ job_details.php?query_string=$1&action=%1 [L] 这是我尝试多次更改但没有成功的RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\\.html$ job_details.php?query_string=$1&action=%1 [L]RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\\.html$ job_details.php?query_string=$1&action=%1 [L]

This code makes the url when for the button: 这段代码为按钮添加网址:

$button = tep_href_link($id.'/'.$title.'.html');

I have research apache directives, regular expressions and tried many tutorials but whenever I change anything in the htaccess for that line I get sent to the wrong url or the site crashes altogether. 我有研究apache指令,正则表达式并尝试了许多教程,但是每当我为该行更改htaccess中的任何内容时,我都会发送到错误的url或网站完全崩溃。

I think it is impossible you can use this url instead : 我认为您无法使用此网址来代替:

http://example.com/jobs/97006/data.html http://example.com/jobs/97006/data.html

   RewriteEngine On
   RewriteRule ^jobs/([^/]*)/([^/]*)\.html$ /job_details.php?query_string=$1&action=$2 [L]

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

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