Forum Moderators: phranque
I`m looking for rewrite rule which will translate url from
exmaple.com/index.php/en/folder1/news1
to
example.com/en/folder1/news1/
In other words, I want to remove index.php from my URL.
When user will access www.example.com/en/folder1/news1/ mod_rewrite will look in www.exmaple.com/index.php/en/folder1/news1.
I`m not strong in writing reqular expressions.
Thank you for any help.
I`m using PHP script in my CMS which reads data from PATH_INFO
<?php
$arrParams = array();
$arrParams = explode( '/', substr( $_SERVER['PATH_INFO'], 1) );
echo '<pre>';
var_export( $arrParams );
echo '</pre>';
?>
so I have nice urls like exmaple.com/index.php/en/folder1/news1
Is possible to remove index.php from URL using mod_rewrite?
Can user access URL like example.com/en/folder1/news1/ and it will be translated to exmaple.com/index.php/en/folder1/news1
JDMorgan, could you?
Best regards
mod_rewrite works on *incoming* requested URLs, and takes effect as URLs are translated into filepaths or script calls -- It is not an 'output filter' that can change what appears on your pages.
Once you have published friendly URLs on your pages, then you can add mod_rewrite code -- or probably easier for you in this case, modify your script, to translate those friendly URLs back into the form needed to access your CMS/database and generate the requested next page.
Remember that a URL exists only outside the server; A server's job is to translate a URL to a filepath or to activate a script to generate content. This explains why your script must publish friendly URLs on your pages, because the links on the pages, clicked and sent in requests to your server, are the only place that URLs exist.
For more details on this, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com], particularly the first basic mod_rewrite thread in the library.
Jim