My htaccess file contains this
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
this redirects all requests to my index.php page, which includes different files as required. That file brakes the url on the basis of /
and gives output as an array.
$request = split("/", $request);
If someone accesses mywork/yash
, the query works fine as $request[0]
becomes yash
. But when I program for $request[1]
it gives a undefined offset
error.
I know this error arises when an array index which is undefined is accessed, but when mywork/yash/
is acccessed, the error doesn't occur anymore !.
Can someone tell me the .htaccess
rule to add a tail-ending slash after every request so as soon as the user types mywork/yash
it gets converted to mywork/yash/
.
Thanks in advance !
/
, so this doesn't make sense. You will never seemywork/yash
as a path. It will always be/mywork/yash
. Did you miss some important details in your question?$request
coming from? And what does it contain? (It obviously doesn't containmywork/yash
.)split()
is deprecated, you should be usingexplode()
instead. The problem would seem to be with your processing of$request
, not with a trailing slash - the two are unrelated?yash
. I want to add tail ending/
to all links which user writes in the addressbar