简体   繁体   中英

Rewrite dynamic url in .htaccess?

Here is an example url. 97006 is the query string. 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.

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

In the .htaccess there is already code for the url I want to change.

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]

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.

I think it is impossible you can use this url instead :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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