Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache lookback

Status
Not open for further replies.

kbc1

Programmer
Feb 23, 2007
5
GB
Hi

I am about to begin developing my first 'tidy url' website with PHP and have followed many tutorials on how to implement the ForceType method. However, each time i try and type a URL such as (where articles is my script and 3 would be the ID of the article in my database) I simply get a 404 error page everytime, even though I have the data in my database.

It would suggest to me thet the Apache LookBack facility that I aparently need to work is not happening for me. Can anyone help me ensure that this is enabled and means of testing that it is working please?

Many Thanks in advance.
K
 
Hi

Error 404 has nothing in common with the [tt]ForceType[/tt] directive. That helps if the content is received, but the browsers does not interpret it as desired.

You have to use mod_rewrite module to internally change that "tidy URL" to the real one. For example :
Code:
RewriteRule ^(.+)/(.*) $1.php?id=$2

Feherke.
 
Hi fererke

I am very new to this mod_rewrite stuff and have searched many a forum and tutorials to find out more but i'm still none the wiser!

Can you please explain what that line of code does?

It will greatly help me understand my approach to the website.

Many Thanks

 
Hi

kbc1 said:
have searched many a forum and tutorials to find out more
No need to search too much. My previous post contains this link :

And the above document contains further links :

And the above documents contains a lot of examples and explanations.

Ok, I try to explain the transformation. Ignore the inserted extra spaces, is just for aligning the related parts.
Code:
[gray]#                 [highlight #eee]original      [/highlight] [highlight #ccc]changed            [/highlight][/gray]

RewriteRule      ^[highlight #fee](.+)[/highlight]     /[highlight #eef](.*)[/highlight] [highlight #fcc]$1[/highlight]       [highlight #cfc].php?id=[/highlight][highlight #ccf]$2[/highlight]
[URL unfurl="true"]http://example.com[/URL][highlight #fee]/articles[/highlight]/[highlight #eef]3[/highlight]
[URL unfurl="true"]http://example.com[/URL]               [highlight #fcc]/articles[/highlight][highlight #cfc].php?id=[/highlight][highlight #ccf]3[/highlight]

[gray]#                 [highlight #eee]requested     [/highlight] [highlight #ccc]served             [/highlight][/gray]
Of course, you have to know regular expressions to fully understand the above directive.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top