?
Solved

Decypher this .htaccess file please

Posted on 2006-05-04
6
Medium Priority
?
295 Views
Last Modified: 2008-02-01
I just installed and configured TextPattern on a site of mine. I like the way that it does the URLs because it's not some stupid index.php?a=146 style link. It does all the stuff as /category/ArticleNumber/PostTitle (ie: url.com/networking/4/cool-sounding-article)

There is, of course, no path like that actually on the server. Everything is pulled from the database and it just looks like a valid path courtesy of a mod-rewrite (I think that's what's doing it)

Here's the .htaccess file's contents:


#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.+) - [PT,L]
 
 RewriteRule ^(.*) index.php
</IfModule>

#php_value register_globals 0


Can somebody decypher that line-by-line? It utterly confuses me.

Forgive my idiocy, and thank you in advance. -Sootah
0
Comment
Question by:Sootah
  • 3
  • 3
6 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 16612452
comment
comment
comment
(empty line)
conditional directive starts
enable mod_rewrite functionality
a condition for mod_rewrite (the request URI must exist as file path) OR
a condition for mod_rewrite (the request URI must exist as directory path)
if condition matches use URL as is
(empty line)
if condition matche and this one is reached replace URL by index.php
end of conditonal directive
(empty line)
comment
0
 
LVL 2

Author Comment

by:Sootah
ID: 16613207
Hah, now it makes even less sense to me.

I don't get at what point it converts the /non/existant/path into an index.php?articlenumber=whatever (or whatever format textpress uses)

OR, is the .htaccess merely telling the server if the path literally does not exist simply go to index.php with no special extras? In that case, how does TextPattern know what article to go to? You'd think that it'd just show the homepage regardless. Does the requested URL get passed to TP somehow?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16613652
the -f and -d option do not use the query-string, for obvious useless reason

> how does TextPattern know what article to go to?
what do you mean by TextPattern?
if you mean the query-string, then you posted conditions and rules to not talke care about it
0
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

 
LVL 2

Author Comment

by:Sootah
ID: 16613746
TextPattern is a Content Management System, like WordPress (or Blogger)

When I go to a specific article URL, like /section/category/article-title it takes me to it even though that path does not actually exist. How is the information being passed to TextPattern so that it knows what to load?
0
 
LVL 2

Author Comment

by:Sootah
ID: 16613774
Here's the actual URL I'm playing with:

http://www.home-computer-networking.net/articles/7/test-article

on the server, /articles does not exist. Subsequently, nothing inside of it exists either. Somehow the URL requested is getting passed to the TextPattern software so it knows what article to load.

Also, I'm playing with what the permalink structure looks like, so I'm not totally sure that URL will continue to work. (Should give you an idea as to what I'm talking about though.)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16613863
if you mean that   articles/7/test-article  is passed somehow to the new URI (index.php), then the answer is no
To do that you need to know how these strings should be passed to index.php, and then define the RewriteRule proper.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Loops Section Overview
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question