Jump to content


Photo

Need A Bit Of Help With Mod Rewrite In Htaccess.

mod rewritehtaccess

  • Please log in to reply
6 replies to this topic

#1 SuperMAG

SuperMAG

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 29 December 2012 - 12:56 PM

Suppose i have custom pages like

http://www.myfootbal...results-tables/
or
http://www.myfootbal...e/6/contact-us/

I want to remove the page/6/, i want to make it look like this:

http://www.myfootbal...results-tables/
or
http://www.myfootbal...com/contact-us/

I checked few examples, but the code was a bit complicated for me to understand. I know you have to make some sort of rule in the mod rewrite. Any help will be appreciated.

#2 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 29 December 2012 - 01:07 PM

How would the server know which page to display then?
Keeping it simple.

#3 SuperMAG

SuperMAG

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 30 December 2012 - 04:07 AM

mmm, well lol i donno. can i do this page per page. like a code for every page link, i also want to redirect the old pages to new ones.

#4 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 892 posts
  • LocationLondon, UK

Posted 30 December 2012 - 06:58 PM

Most mod_rewrite applications just redirect to a single page which interprets the URL. There's usually a format such as http://website.com/m...tion/arg1/arg2/ but it varies from app to app. The application works out the correct content to show and the MVC architecture apps usually use a Router class.

Why is this relevant to you? Because I think, you think all the leg work is done in htaccess when in reality its not. More permanent things could be done in htaccess such as a 301 redirect.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#5 SuperMAG

SuperMAG

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 31 December 2012 - 08:11 AM

well i would like to avoid having 10/15 folders with index.php inside it on the main website. thats all. i know about redirect through htaccess, as it can be done from my cpanel too.

#6 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 892 posts
  • LocationLondon, UK

Posted 31 December 2012 - 11:07 AM

What's the purpose of your 10/15 index.php files?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#7 SuperMAG

SuperMAG

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 01 January 2013 - 01:12 AM

well the other way is that i create a folder and name it as /contact-us/, then put it main public html, i have to do that with all other pages.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com