Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Nice urls with .htaccess and PHP!


  • Please log in to reply
19 replies to this topic

#13 Orjan

Orjan

    CC Mentor

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

Posted 27 September 2012 - 11:33 AM

in .htaccess you add code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]

as stated earlier. in that case, the url from PHP perspective is as all calls was index.php?page= followed by the rest of the url. in PHP, you will then get the parameters from $_GET['page'] and then, you make some kind of work on how to treat the parameters. how to do it has millions of ways, so you need to choose one, maybe first parameter is pagename and send the rest to the page to deal with?
  • 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.


#14 macroose

macroose

    CC Regular

  • Member
  • PipPipPip
  • 40 posts
  • Programming Language:PHP, JavaScript
  • Learning:PHP, JavaScript

Posted 31 October 2012 - 07:05 AM

Like you did in your first post.

http://www.site.com/...x.php?page=home redirects to http://www.site.com/home

but if we try with http://www.site.com/...x.php?page=home it still works.

I actually don't want http://www.site.com/...x.php?page=home URL to work if http://www.site.com/home URL is working perfectly.
  • 0

#15 Orjan

Orjan

    CC Mentor

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

Posted 31 October 2012 - 07:13 AM

Well, I see no problem with the link working, as if you just never use it or show it to anyone, no-one knows it's working.
  • 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.


#16 macroose

macroose

    CC Regular

  • Member
  • PipPipPip
  • 40 posts
  • Programming Language:PHP, JavaScript
  • Learning:PHP, JavaScript

Posted 31 October 2012 - 07:24 AM

Well, I see no problem with the link working, as if you just never use it or show it to anyone, no-one knows it's working.


Yeah you are right but I am just this for knowledge purpose.
I just want to know if we can do this or not. :)
  • 0

#17 vimla

vimla

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 06 May 2013 - 09:37 PM

Hello Alexander,

 

Can you guys please tell how can i achieve clean url from  http://domain.com/fl...&flights_id=138

 
to
 

 

 

it might be teh easy one, but i am new to php and htaccess please help me out


  • 0

#18 ali156354

ali156354

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 27 September 2014 - 08:26 AM

i have a big problem in code....


  • 0

#19 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 28 September 2014 - 12:42 AM

Ali, what seems to be the problem?


  • 0

#20 ThomasTedsmall

ThomasTedsmall

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 18 December 2016 - 01:01 PM

hi,i am using woocommerce deposits plugin,the problem is that plugin collects taxes upfront,but i need 10 before and 10 after this should be code for it PHP Code:
  • 0