regex - Having an issue with .htaccess mod rewrite assistance appreciated -


thanks in advance help...

i creating cms styles , formatting given page dynamically generated depending on type of page (general, member, download,etc.). in past have used following .htaccess identify page type:

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l  rewriterule ^general/(.*)$ general.php?title=$1 [qsa,l] 

which works fine required me create rendering page each page type... general.php, member.php, download.php, etc.

what trying is...

through .htaccess have wild card identify page type have pages render single [page.php] file page types can created on fly without have create rendering page each page type.

i having issue $ sign showing in results. know enough .htaccess dangerous... assistance appreciated...

this test php

<?php  $type = $_request['type']; $title = $_request['title'];  echo $type.'<br>'.$title;  ?> 

this url:

http://my-site.com/general/this-is-a-general-page

with .htaccess rewrite rule set as:

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l  rewriterule ^(.*)/(.*)$ temp.php?type=$1$&title=$2 [qsa,l] 

produces:

general$ this-is-a-general-page 

i can't figure out why $ @ end of page type. have tried removing $:

rewriterule ^(.*)/(.*) temp.php?type=$1$&title=$2 [qsa,l] 

but getting same result...

again, in advance help. pete

you can use:

rewriteengine on  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^([^/]+)/([^/]+)/?$ temp.php?type=$1&title=$2 [qsa,l] 

you had stray $ after $1 in rule.

ps: have tweaked regex little make more efficient.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -