TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-02-2008, 02:54 PM   #1 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default mod_rewrite

Well I've worked with it before but this time it's just not cooperating. I need to turn this..

http://domain.com/index.php/member/foo/this

into

http://domain.com/index/member/foo/this

I got the impression it would be something like this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ $1/
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.

Last edited by Salathe : 04-02-2008 at 05:35 PM. Reason: Fixed URL display
TlcAndres is offline  
Reply With Quote
Old 04-02-2008, 03:10 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

I may be wrong about this, but shouldn't it be the other way around?

RewriteEngine On
RewriteRule ^/([A-Za-z]+)/ /$1.php
delayedinsanity is offline  
Reply With Quote
Old 04-02-2008, 05:42 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

You'll probably want something more along the lines of:
Code:
<IfModule mod_rewrite.c>
	RewriteEngine On

	# Redirect all requests to index.php
	# if file doesn't exist
	# and directory doesn't exist
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^index/(.*)$ index.php/$1 [L]

</IfModule>
The RewriteCond lines make sure that the rewriting only happens if the URL is not otherwise normally accessible (useful for images, CSS, etc.). The RewriteRule line rewrites URIs starting with index/ as you requested.
Salathe is offline  
Reply With Quote
Old 04-02-2008, 05:52 PM   #4 (permalink)
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default

Well, do there really have to show that index?

ie.
Code:
http://domain.com/member/foo/this
and we call it like this
Code:
http://domain.com/index.php?mode=member&cat=foo&do=this
We put htaccess like this

Code:
RewriteEngine On

RewriteRule ^/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?mode=$1&cat=$2&do=$3 [QSA,L]
I don't know how familiar you are whit mod_rewrite so I try explain something about that.
In the end you find those tags, if I recall correct QSA allows more definitions in url end (domain.com/member/foo/this/?newdef=likethis)
and L says that rule ends there.

If you like, you can do all your files look like "folders".. Well I put some examples bellow:

Code:
http://domain.com/customers.php => http://domain.com/customers/
or

Code:
http://domain.com/folder/mypanel.php => http://domain.com/folder/mypanel/
do

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*[^/])/?$ $1.php [L,QSA]
As you can see, the are those tags again so you can add more definitions in urls end if you like or add new rules in htaccess.

Hope these help you and please don't kill me if won't work as it is presented in your system. Those should because I use them ATM! ;)
Send a message via MSN to marxx
marxx is offline  
Reply With Quote
Old 04-02-2008, 08:41 PM   #5 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

I never really got mod_rewrite, do those codes work for every variable, or do you need to change it depending on the get variables you want to pass?
__________________
Signatures are nothing but incriminating.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:25 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design