URL assumed "index.html" (or in our case, "index.php")

Events happening in the community are now at Drupal community events on www.drupal.org.
Dr. DOT's picture

I am converting a site that makes link reference to ../directory/

It assumes ../directory/index.php

Yet when I click on the link I get a "The requested page could not be found." If I extend the URL manually by typing index.php at the end, I get the page I need to in Drupal.

How can I make Drupal behave like my httpd.conf file behaves in these cases?

Comments

_

scottatdrake's picture

Is there any particular reason you need to have file extensions (.php, .html, etc) at the end of your urls? It's pretty unusual with Drupal, probably unnecessary, and may be causing some of the problems you are having.

Rewrite to fix old URLs

newz2000's picture

You can create a rewrite rule in your .htaccess file (that comes with Drupal) to fix urls.

Having .php at the end of your URLs is bad because it:

  • reveals your site's architecture
  • makes your URLs dependent on a certain architecture
  • looks messy

So to fix this and automatically redirect people to a URL that does not have a .php at the end, or for a path that ends in / to the version w/out the / you could use something like this: (untested)

RewriteRule ^(.+).php$ /$1 [L,R=301]
RewriteRule ^(.+)/$ /$1 [L,R=301]

To explain what I'm suggesting, rule 1 looks for any URL that has one or more of any characters and ends in .php and then replace it w/ the part before the . in .php.

Rule #2 looks for a URL that has one or more characters and ends in a / and replaces it with the everything except the trailing /.

In both of these cases 301 redirects are done which tells the browser (and Google) that the old URL is dead, use the new one instead. Leave off the =301 part (so it looks like [L,R] ) while testing.

Now, if you had a page called yoursite.com/abc.php or /abc/123.php you create a URL alias of abc or abc/123 and when someone goes to abc.php they'll see abc and for abc/123.php they'll see abc/123. Likewise if your URL was yoursite.com/abc/ give your page the alias abc

--
Matthew Nuzum
newz2000 on freenode

directory Index

raghu_gh's picture

Hi,
I am also having same problem. I have installed drupal and retained old html pages also. But directory/ is not redirecting to directory/index.html though index.html is present in the directory.
what is the syntax for .htaccess file to overcome this.
Raghu

Add the following line to the

jrearick's picture

Add the following line to the .htaccess file

DirectoryIndex index.php index.htm index.html

Thanks for your reply but still same problem

raghu_gh's picture

I Thanks for your reply. I have added in the .htaccess file. But still showing page can not display

Thanks
Raghu

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: