Clean URLs are lost when cakePHP applications are integrated with drake
pearcec - April 24, 2007 - 17:09
| Project: | Drake :: Drupal-CakePHP bridge |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Is it possible to add this?

#1
If you are talking about the /drake?run=foo URLs, there are a couple things that could be done.
1. Provide a mod_rewrite rule in your .htaccess file for rewriting Drake URLs
Example: (Place before index.php rewrite rules)
# Rewrite Drake URLsRewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule myapp/?(.*)$ index.php?q=drake&run=$1 [L]
2. Patch the drake module so that instead of parsing out the drake?run=foo URLs, tell it to simply print myapp/foo
This is by no means an elegant solution, but I will personally be looking for a solution to this. I'm thinking maybe integrating path module and an additional drake.ini parameter could be a better solution. It would also be nice to simply use the variables table instead of the drake.ini file to be more in line with the "drupal" way.
#2
I started to modify drake.module to support clean urls. I don't think it will be to bad. I had a lot of success. But it is all hacked up right now. I am going to post a patch once I clean it up.
#3
I've submitted a patch at: http://drupal.org/node/143273
The patch does part of the URL re-writing in allowing you to change the default Drake URI (e.g. /drake -> /myapp).
I think the only thing left to complete clean URL support would be to compliment that effort with some internal URL parsing in Drake.
That is, when clean URLs are enabled in Drupal, it should not be necessary to add '?run=' and URL encode the cakePHP URIs. Likewise, it should check the request URI and split on $drake_uri/ to get the cakePHP URI when clean URLs are enabled.
Example:
Drake URI: myapp
Incoming request: example.com/myapp/cake/uri
Cake URI: cake/uri
#4
Here's a patch file that combines the Custom URI in the other patch with support for Drake handling/parsing clean URLs.
This patch modifies:
1. drake.module: parsing of application settings, parsing of run= URL, ignoring application not set when clean URLs are on.
2. lib/drake.class.php: URL manipulation
3. lib/cake_embedded_dispatcher.class.php: modifies pass through URL for clean URLs when on.
I've got clean URLs working and I can customize the default drake URI. Getting clean URLs working without adding the custom drake URI shouldn't be too difficult to accomplish.
#5
I removed the other patch code. This version contains only the patch code to provide clean URLs using the original 'drake' URI.
The reason I had added the other patch was to make rewriting complete since using mod_rewrite or adding a URL alias using the path module does not work by themselves (a combination of the two does work, however).
I'm thinking that the path module may (in the future) add support for wildcarded aliases, which would work well for Drake.
Until then, the steps to getting full re-written URLs (including the 'drake' URI) are to do the following:
1. Patch Drake for clean URLs.
2. Add the mod_rewrite rule to replace 'drake'. (processes only incoming URIs)
3. Add a URL alias that matches the mod_rewrite rule to replace 'drake'. (processes only the base URI for incoming, processes alias for all outgoing URIs).
#6
I tried the "clean_urls_only.patch", this works as expected. as I stated in the other issue you submitted, I don't see the need to change the word drake to something else. Other might, either way doesn't matter to me.
#7
#8
I meant to change it to ready to be committed. I wonder if we can get a new release. We should probably go 1.0 with this.
#9
Hi, im fairly new to drupal dev, so if i'm wrong i apologise. I just manually patched my drake module for clean_urls and found that it brings up warnings if you dont specify a default value for variable_get(), ie when you test for if(variable_get('clean_urls')). This is obviously only a warning but annoying nevertheless when you are developing, so would it be more convenient to add the default '0' to variable get functions mainly to remove the warning and then also the if() would return false if for some reason it could not get hold of the variable_get('clean_urls').
Here is the patch with variable_get('clean_url') changed to variable_get('clean_url', 0)
Can someone just double check it, was just a find->replace job so shouldn't cause any problem
There are 4 instances of replacements.
#10
sorry, forgot to change the status