Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

How To Remove The Index.php From Url And Other Staffs?

.htaccess apache rewriterule mod_rewrite valid url

  • Please log in to reply
1 reply to this topic

#1 Stasonix


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 04 July 2012 - 10:58 PM

I have a link on my page:

echo "<p><a href='/index.php?cat=".strtolower($name)."&article=".translitIt($value)."'">.$value."</a></p>";

for example it can be like this:


I want to make it clean:


I did rewriterule in .htaccess, but it won't work:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\$ /index.php?cat=$1&article=$2 [L]

if click the link, in the browser I have still sees URL as is.

What can be bad with this?
  • 0

#2 Orjan


    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 05 July 2012 - 05:13 AM

then, you should link to "/php/array", not to "'/index.php?cat=".strtolower($name)."&article=".translitIt($value)."'

what the rewriting does is that when recieving a url like "/php/array/ it will rewrite it to the form /index.php?cat=$1&article=$2
so you can treat it as the later form in php even if it is in the first form to the user.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.

Also tagged with one or more of these keywords: .htaccess, apache, rewriterule, mod_rewrite, valid url

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download