I initially thought this problem was favicon related (boy is my face red). Anyway, I'm trying to redirect old urls from our old site like

<IfModule mod_rewrite.c>
  RewriteEngine on
  
  # CUSTOM: rewrite old urls to new clean urls
  RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ /articles/$1/ [R=301,L]

  # 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>

The rule I added (next to # CUSTOM) is what broke the site. Any idea why this would suddenly make drupal not see the css? Is there a way to keep it from executing the rule on css files? It's a shame because the rules works, and I have a lot of urls this fixes which we need to be fixed...any help is appreciated.

Comments

Ravan’s picture

You might want to put a condition rule above it... Something to make it skip the rule in case of .css extentions, maybe?

Try testing this:
RewriteCond %{REQUEST_URI} ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ [NC]
RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
RewriteRule . /articles/$1/ [R=301,L]

tdellaringa’s picture

Well, that seems to fix the CSS issue, but now the rewrites are not working :/

Here is the whole htaccess as it stands now

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On
  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600
  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<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
  
  RewriteCond %{REQUEST_URI} ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ [NC]
  RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
  RewriteRule . /articles/$1/ [R=301,L]
  
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.81 2007/01/09 09:27:10 dries Exp $

# bump up upload limit for audio files
#php_value upload_max_filesize 10M
#php_value post_max_size 20M

php_value memory_limit 25M

ronan’s picture

Are you running Drupal in a subdirectory (example.com/mysite/)? If so you might want to try adding a rewrite base:

RewriteBase /mysite/

------------------------------------
Gorton Studios - Websites that Work. http://www.gortonstudios.com/
http://www.gortonstudios.com/portfolio/technologies/drupal

------------------------------------
Ronan
Founder - NodeSquirrel - https://www.nodesquirrel.com/
Agency Tools Lead - Pantheon - https://www.pantheon.io/

ronan’s picture

Rewrite Conditions only apply to the rule that immediately follows them, so you might want to change your rewrite rules to:

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d  
  RewriteCond %{REQUEST_URI} ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ [NC]
  RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
  RewriteRule . /articles/$1/ [R=301,L]

  # 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>

or

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d  
  RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
  RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ /articles/$1/ [R=301,L]

  # 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>

or even

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d  
  RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+?)/?$ /articles/$1/ [R=301,L]

  # 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>

See if any of those work. Sometimes getting rewrite rules right is a matter of trial and error.

------------------------------------
Gorton Studios - Websites that Work. http://www.gortonstudios.com/
http://www.gortonstudios.com/portfolio/technologies/drupal

------------------------------------
Ronan
Founder - NodeSquirrel - https://www.nodesquirrel.com/
Agency Tools Lead - Pantheon - https://www.pantheon.io/

tdellaringa’s picture

The middle one seemed to work, until I realized my most important most hit article link was broken, all I get now is my articles page. So I removed the rewrites, reverted back to the default .htaccess I had, and it still doesn't work. Our most hit link was

2006/07/28/10-claims-in-the-bible-on-the-deity-of-christ/

which needed to be changed to

articles/10-claims-in-the-bible-on-the-deity-of-christ/

But now, all I get is the articles page - even after I deleted and re-created the article entirely with a different URL ... so this link

http://www.crossandthrone.com/articles/ten-claims-in-the-bible-on-the-de...

(changed 10 to ten) does not give me the actual article, but instead the same content you would see on

http://www.crossandthrone.com/articles

This is crazy. I turned off caching. I don't know why that link won't work. Now I wish I had never even tried this, at least with the 404 page I can let people know things have changed, now they just get a page that makes no sense to them at all.

ronan’s picture

That's strange, but I don't think it's related to the url rewriting.

Go to the path alias admin page and make sure there is only one alias with that url, then remove the '/' from the end of the alias and see if that helps

R
------------------------------------
Gorton Studios - Websites that Work. http://www.gortonstudios.com/
http://www.gortonstudios.com/portfolio/technologies/drupal

------------------------------------
Ronan
Founder - NodeSquirrel - https://www.nodesquirrel.com/
Agency Tools Lead - Pantheon - https://www.pantheon.io/

tdellaringa’s picture

Yep, you were correct, somehow I must have had duplicates - I noticed a couple other dupes in there - so you can only have one alias for each node? For example, if I have this node:

node/95

I can only have one url alias, or I will have problems?

Thanks again, I will try the other rewrite rules again.