You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Thierry Kennes <tp...@gmail.com> on 2007/07/14 00:25:45 UTC

[users@httpd] RewriteRule with a dot in URL

Hi there, 
I completely new in Apache config and all that stuff. 
I've got a wiki (for example : http://wiki.thierrykennes.com) 
and when I want to create a page Test.com 
so that it looks like this : http://wiki.thierrykennes.com/Test.com, it
doesn't work because of the dot. 

I was told to look on .htaccess about "RewriteRule" and I thought of adding
somethg like that : 
RewriteRule (.*)\.(.*)$ substitution 
Is my pattern right ? and also what can I put instead of "substitution" ? 

Thanks a lot for your further reply. 

ps: and sorry for my bad english :)
-- 
View this message in context: http://www.nabble.com/RewriteRule-with-a-dot-in-URL-tf4077207.html#a11588567
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule with a dot in URL

Posted by Joshua Slive <jo...@slive.ca>.
On 7/16/07, Thierry Kennes <tp...@gmail.com> wrote:
>
> I've just tried :
> RewriteRule ^Test\.com$ Testcom
> and
> RewriteRule (.*)\.(.*) $1$2
> as you suggested.
>
> Here is the message i get with the browser : The requested URL /Test.com was
> not found on this server.

Server error and access logs (and often the RewriteLog) are
indispensable when doing debugging. In this case, however, I can make
a guess for you based on the config you posted.

> RewriteRule ^[^:]*\. - [L]

> # anything else is to be treated as a title
> RewriteRule ^(.+)$ /wiki/index.php?title=$1 [L,QSA]

The RewriteRule that excludes files with dots is probably there to
make it easier to access static content. There are several
alternatives, such as testing directly if the static content exists on
the disk, or being more specific about the static content you want to
exclude.

But in the interest of giving you a minimal change to get things
working, you can likely just insert ABOVE that first RewriteRule I
quote, some specific cases that you don't want to exclude. For
example:

RewriteRule ^Test\.com$ /wiki/index.php?title=Test.com [L,QSA]
(You might need to use Testcom in place of Test.com in the query
string depending on the other restrictions imposed by Mediawiki.)

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule with a dot in URL

Posted by Thierry Kennes <tp...@gmail.com>.
I've just tried :
RewriteRule ^Test\.com$ Testcom
and
RewriteRule (.*)\.(.*) $1$2 
as you suggested.

Here is the message i get with the browser : The requested URL /Test.com was
not found on this server.

the .htaccess file :
RedirectMatch ^/wiki/([A-Z].*)$ http://wiki.tpkennes.com/$1
RewriteEngine on

# ban these abusive bots
RewriteCond %{HTTP_USER_AGENT} hl_ftien_spider_v1.1
RewriteRule .* - [F,L]

# anything that contains a dot without a colon should be left alone
RewriteRule ^(edit)/(.*)$ /wiki/index.php?action=$1&title=$2 [L,QSA]
RewriteRule ^insert/(.*)$ /wiki/index.php?action=edit&title=$1 [L,QSA]
RewriteRule ^(watch)/(.*)$ /wiki/index.php?action=$1&title=$2 [L,QSA]
RewriteRule ^(delete)/(.*)$ /wiki/index.php?action=$1&title=$2 [L,QSA]
RewriteRule ^(protect)/(.*)$ /wiki/index.php?action=$1&title=$2 [L,QSA]
RewriteRule ^(history)/(.*)$ /wiki/index.php?action=$1&title=$2 [L,QSA]
RewriteRule ^[^:]*\. - [L]

# anything that contains a slash without a colon should be left alone
RewriteRule ^[^:]*\/ - [L]
# redirect to main page

RewriteRule ^/*$ /wiki/index.php?title=Main_Page [L,QSA]

# anything else is to be treated as a title
RewriteRule ^(.+)$ /wiki/index.php?title=$1 [L,QSA]
# anything that contains a slash is to be left alone.


Joshua Slive-2 wrote:
> 
> On 7/16/07, Thierry Kennes <tp...@gmail.com> wrote:
>>
>> Thanks Joshua for your advice.
>> Though it didn't worked. It's like if the server is trying to find a file
>> named "Test.com" like if it was index.php.
>> So i don't know what should i have to do ... btw, i'm using mediawiki.
> 
> Statements like "it didn't worked" aren't going to get you anywhere.
> We need to know exactly what you tried, and exactly what the result
> was including messages in the browser and the server error and access
> logs. It would also be helpful to know what apache configuration is
> being used to activate mediawiki.
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RewriteRule-with-a-dot-in-URL-tf4077207.html#a11640409
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule with a dot in URL

Posted by Joshua Slive <jo...@slive.ca>.
On 7/16/07, Thierry Kennes <tp...@gmail.com> wrote:
>
> Thanks Joshua for your advice.
> Though it didn't worked. It's like if the server is trying to find a file
> named "Test.com" like if it was index.php.
> So i don't know what should i have to do ... btw, i'm using mediawiki.

Statements like "it didn't worked" aren't going to get you anywhere.
We need to know exactly what you tried, and exactly what the result
was including messages in the browser and the server error and access
logs. It would also be helpful to know what apache configuration is
being used to activate mediawiki.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule with a dot in URL

Posted by Thierry Kennes <tp...@gmail.com>.
Thanks Joshua for your advice.
Though it didn't worked. It's like if the server is trying to find a file
named "Test.com" like if it was index.php.
So i don't know what should i have to do ... btw, i'm using mediawiki.



Joshua Slive-2 wrote:
> 
> When you say "it doesn't work because of the dot", what exactly does
> that mean? Your wiki software doesn't support that type of file name?
> If so, you can indeed hide the true name using mod_rewrite with
> something like
> RewriteRule (.*)\.(.*) $1$2
> 
> I wouldn't suggest using a rule exactly like that, however, since it
> could lead to undesired (and possible dangerous) rewriting. Try
> something more specific like
> RewriteRule ^Test\.com$ Testcom
> (with the possible addition of an appropriate RewriteBase directive)
> or if you use httpd.conf instead of .htaccess
> RewriteRule ^/Test\.com$ /Testcom
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RewriteRule-with-a-dot-in-URL-tf4077207.html#a11638593
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule with a dot in URL

Posted by Joshua Slive <jo...@slive.ca>.
On 7/13/07, Thierry Kennes <tp...@gmail.com> wrote:
>
> Hi there,
> I completely new in Apache config and all that stuff.
> I've got a wiki (for example : http://wiki.thierrykennes.com)
> and when I want to create a page Test.com
> so that it looks like this : http://wiki.thierrykennes.com/Test.com, it
> doesn't work because of the dot.
>
> I was told to look on .htaccess about "RewriteRule" and I thought of adding
> somethg like that :
> RewriteRule (.*)\.(.*)$ substitution
> Is my pattern right ? and also what can I put instead of "substitution" ?
>
> Thanks a lot for your further reply.
>
> ps: and sorry for my bad english :)

When you say "it doesn't work because of the dot", what exactly does
that mean? Your wiki software doesn't support that type of file name?
If so, you can indeed hide the true name using mod_rewrite with
something like
RewriteRule (.*)\.(.*) $1$2

I wouldn't suggest using a rule exactly like that, however, since it
could lead to undesired (and possible dangerous) rewriting. Try
something more specific like
RewriteRule ^Test\.com$ Testcom
(with the possible addition of an appropriate RewriteBase directive)
or if you use httpd.conf instead of .htaccess
RewriteRule ^/Test\.com$ /Testcom

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org