norman.lol
norman.lol

Reputation: 5374

How to redirect from URL with a trailing dot?

Having a Drupal here. In that Drupal is a folder with another Drupal. So in another Drupal's .htacces the base was rewritten like this Rewrite Base /another-drupal and everything's fine.

Now, printed invitations were send to customers to look at the another Drupal via its URL adrupal.com/another-drupal. And like right now the URL stands at the end of a sentence and the dot looks like it is part of the URL. How do I redirect all users who entered the URL with a trailing dot to the correct URL without the trailing dot? And in which .htaccess do I have to do that? The parent's Drupal .htacess? Or in the another Drupal's .htaccess?

I allready tried that approach: Redirect url to home page with trailing dots, but it didn't work. Is it maybe because in that example they have two dots?

Upvotes: 1

Views: 1901

Answers (2)

anubhava
anubhava

Reputation: 785481

Looks like this simple rule is all you need:

RewriteRule ^(.+?)\.$ $1 [L,R=301]

This will remove trailing period (dot) from any URL.

Upvotes: 1

Jon Lin
Jon Lin

Reputation: 143906

Try:

RewriteCond %{THE_REQUEST} \ /([^\?\ .]*)\.(?:\?|\ |$)
RewriteRule ^ /%1 [L,R=301]

Upvotes: 3

Related Questions