cleaning drupal query string

rinehart - January 18, 2004 - 11:30

Hi,

I believe I have the url rewrite module working, but I'm having trouble cleaning the query string for Drupal. I'm pretty sure this is the case because I was able to use Drupal's url aliasing module to change 'forum/1' to 'book-club' on my site. What I'd like to do is remove that '?q=' from my url. Every time I try to create a url alias for the expression I get a error stating: "The normal path '...' is invalid"

Can anyone provide me with a snippet to illustrate how to do this?

TIA

Mac

Clean URLs

Steven - January 18, 2004 - 12:13

You will need to go to admin > configuration and turn on Clean URLs. You need to have mod_rewrite enabled for this to work.

Clean URLs

rinehart - January 18, 2004 - 19:11

I assume your referring to the path module, which I have turned on. I also have the mod_rewrite feature enabled in Apache. I've tested that both of those are operational by creating an alias to my book club forum. The problem is that when I try to include the query string attributes in an existing path, I get the error. For example,

normal path: ?q=admin/path/add
new path alias: add-alias
error result: the normal path '?q=admin/path/add' is invalid.

normal path: admin/path/add
new path alias: add-alias
valid result: http://127.0.0.1/?q=add-alias

Can someone please advise on what I need to do to remove the '?q=' from my url?

Forgot to mention before that I'm using 4.3.2, Apache 1.3.29, PHP 4.3.4, on WIN32

- Mac

There is a single option

Steven - January 18, 2004 - 19:56

Just turn on Clean URLs in the *main* admin > configuration screen. That's all.

URL aliasing/path.module is for renaming specific URLs and has nothing to do with ?q=.

one step forward, two steps back

rinehart - January 19, 2004 - 01:49

Steven, thanks - I didn't see that option before.

I turned it on and unfortunately I still have my problem. And in the process of fiddling I foolishly closed my session, so now I can't log in or access any of the administration pages since my login is submitted in the Clean URL format but the clean url is not a valid url. Here's what I've got:

in httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

ServerName 127.0.0.1
DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs/drupal-4.3.1"
Directory "C:/Program Files/Apache Group/Apache/htdocs/drupal-4.3.1"
IfModule mod_dir.c
DirectoryIndex index.php
IfModule
AccessFileName .htaccess

without mod_rewrite this allows me to access the site at http://127.0.0.1. But without signing in I am not authorized to view any content or navigate to the administration section.

I'm then using the standard .htaccess in the /drupal-4.3.1 directory, with the rewiteEngine turned on. Since the drupal index.php set as the directory index for my server, I don't think I need to use the RewriteBase option.

Does anyone have a tip on how I can go through a backdoor to turn clean urls off? And if there are any other tips on things I can do to trouble shoot this issue please let me know.

Thanks,

Mac

Problem solved and documented

rinehart - January 19, 2004 - 09:34

Hi all. I resolved the problem. Actually the solution was listed in a previous post but it took me a while to find it. Since I haven't see a documentation that lays out the process for enabling clean urls step by step, here's what I did for future reference:

  1. In Appache's conf/httpd.conf do the following:
    1. uncomment LoadModule rewrite_module modules/mod_rewrite.so
    2. uncomment AddModule mod_rewrite.c
    3. in the drupal directory node, set AllowOveride All
  2. In root directory of drupal, edit .htaccess:
    1. verify RewriteEngine on
    2. set RewriteBase if required
  3. In Drupal navigate to /administer/configuration and set Clean URLs to Enabled.

I'm not a security expert, so and don't know the full implications of setting AllowOverride All. Any recommendations on more restrictive settings are welcome.

Also noticed a bit of strangness when testing. It seems that when navigating a link the screen was flickering, as if it were loading one page and then promptly reloading the page I requested. It never lasted long enought for me to determine what the first page was, but it was definately noticable that there were two different pages. After a while this went away (perhaps after pages that I was loading were cached). Anyone else notice this?

ur cure for clean url.

dan123 - September 29, 2005 - 14:47

Putting this in the main .httpd.config will also work:

Options FollowSymLinks
AllowOverride All
RewriteEngine on

Do not remove the default but instead add the above block below the default block:

Options SymLinksIfOwnerMatch
AllowOverride None

*** Make sure you provide it the right path to ur drupal folder

 
 

Drupal is a registered trademark of Dries Buytaert.