Forum Moderators: phranque
For the life of me, I can not figure out how drupal cms uses the path module. I'm trying to write a custom classified ads script and my client has a PR of 4. So, i need to be able to use the same rules as drupal cms does...
In .htaccess...
[b]<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
[/b]
Creating a URL Alias is beyond me, this is my first time ever with rewrite :(
In mysql there is
src = /node/2345 or /taxonomy/term/3
dst = index.html etc...
i see the rule in htaccess and see what is in mysql...
but I can't seem to understand this at all...
my app will be mysql driven with smarty template engine
I can't seem to make links.php?page=1245 rewrite to home.htm
Can someone shoot me in the head with the answer?
:)
Thanks much,
Forgive me English - It's bad
~RD
[edited by: RDWest2005 at 3:11 pm (utc) on Aug. 9, 2007]
The "-f" and "-d" RewriteConds are checking for file exists and directory exists. "!" is a logical NOT operator.
So the effect of your code is rewrite any requested URL-path to index.php unless it exists as a physical file or directory. For example, if a robot requests your robots.txt file, and that file exists, then the request will not be rewritten to your index.php script.
I presume that you now need to exclude some additional specific virtual URL-paths from being rewritten to index.php, and wish to rewrite them to your ads script instead. So, to get organized, you will need to define three classes of URLs: Those to be rewritten to index.php, those to be rewritten to you ads script, and those that should not be rewritten at all. Your existing code can serve as an example of the first and third classes, but you'll need to thoroughly define the second class. This only sounds complicated because I'm using generalized language here, due to the fact that I do not know what all of your URLs look like.
Jim
more than likely my links will all be in the form of index.php?page=1234 from the way i code my pagination.
The only other links will be maybe a GET with search or submit GO action like so dev01/links.php?page=1000&Submit=Go
I've not yet included search so I can't post exactly the link i'll come up with.
I was looking through drupal since i've used it in my personal site.
The PATH module is doing a alias from mysql with 3 fields (id,src,dst) so no matter what the original src link is lets say -- domain.com/node/17
now defining an alias in mysql becomes
src = node/17
dst = mypage.htm
and it rewrites whatever term to your alias...
So even if i have to do this a per page basis, that would even be fine...
the main thing is i can't rename his main catagories buz.htm free.htm etc to something like
index.php?page=15 etc because he will loose his PR4
thanks much,
I'm dieing here :(
:)
~R
EDIT, believe it or not, i've run my own servers and provided hosting services for almost 10 years and have never really had to use mod_rewrite except for non-www to www etc - simple rules and i go on about my business :)
[edited by: RDWest2005 at 5:52 pm (utc) on Aug. 9, 2007]
Second, that term you are using: "links." Links on the page determine the URL -- The URL that search engines will follow and the URL that they will list in search results. So, no amount of mod_rewrite internal rewrites can "change" that URL from dynamic to static (search-engine friendly). If you need to do that, then either use preg_replace in the script that produces the page to make the URL static-looking, or change the URL in the database (possibly adding a new entry to each record in the db.
*After* your friendly/static URL is requested, then mod_rewrite can parse it and rewrite it into the dynamic form needed to invoke your script. But mod_rewrite is not an "output filter" for the content of your pages, it is an "input filter" for URLs being requested from your server; Mod_rewrite is invoked after a request arrives from a client, and before any content-handlers or scripts are invoked. It modifies only incoming URLs, so that you can change the filepath that will be used to server content for that URL.
Check out the Apache forum section of the WebmasterWorld library [webmasterworld.com] for more info.
Jim
and it is sent to my script and i grap with GET
i'm seeing a lil light, but i'm still not seeing how i'll do this
~R
I'll tell you what I can't figure out yet.
The seo friendly link is written to the html output to page
eg: <a href=whatever.htm
Now within the drupal PATH module, the whatever.htm is stored as an alias in mysql uder a field (src) the the real link .php?q=x is stored as (dst) destination i assume...
I can't figure out how the regx is taken from mysql with dst and then passed to mod_rewrite with the htaccess I posted at beginning of this thread.
~R
Rather, all requests for non-existent file and directory URL-paths are rewritten by mod_rewrite to invoke the script, with the requested URL-path passed as the "q=" parameter. Based of the requested URL in the "q=" parameter, the script looks up the necessary *files* and variables from the database, and using those variables, it opens, modifies, and/or #includes those files and variables to build the requested "page."
Jim