rewrite subfolder doesn't work

Multi tool use
Multi tool use


rewrite subfolder doesn't work



Following rule doesn't work for subfolder rewriting.


RewriteRule ^cat/([0-9a-zA-Z]+) cat.php?id=$1
RewriteRule ^cat/([0-9a-zA-Z]+)/([0-9a-zA-Z]+) cat.php?id=$1&sid=$2



For example With this rule


<?php
$id='News';
$sid='Politics';
?>
<a href="cat/<?php echo $id?>/<?php echo $sid?>">..</a>



In next page, while echoing $_GET['sid'], it doesn't work


$_GET['sid']


Notice: Undefined index: sid in ...



But this rule


RewriteRule ^cat/([0-9a-zA-Z]+)/([0-9a-zA-Z]+) cat.php?id=$1&sid=$2



works, if only there is two querystring parameters


<a href="cat/<?php echo $id?>/<?php echo $sid?>">..</a>



but it generate ERROR 500 if there is only one parameter


ERROR 500


<a href="cat/<?php echo $id?>>..</a>




1 Answer
1



Try with below,


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cat/([0-9a-zA-Z]+)$ cat.php?id=$1 [L]
RewriteRule ^cat/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)$ cat.php?id=$1&sid=$2 [L]





great. Thanks very much
– AnandHmt
Jul 1 at 6:01






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

xCV6,vjketOi,Y27RFT6XU3zLmdeF
Zd8RH3VJOddR0w9aNqW4BHLTAp2hCdYSQWv7n5Xv N k NeQd I,fgM57,tAaxGi XlmG4nVANea6RjFee6a

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters