FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mod_rewrite rule question
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
mod_rewrite rule question [message #173305] Sat, 02 April 2011 21:54 Go to next message
Corvet is currently offline  Corvet
Messages: 4
Registered: April 2011
Karma: 0
Junior Member
I need set a mod_rewrite rule to map incoming .html and .htm requests to the
(new) real .php extensions.
The following example I find is for .html page: how to adjust rule for both
..html and .htm pages?

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [NC]


thanks.
Re: mod_rewrite rule question [message #173309 is a reply to message #173305] Sun, 03 April 2011 00:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/2/2011 5:54 PM, Corvet wrote:
> I need set a mod_rewrite rule to map incoming .html and .htm requests to the
> (new) real .php extensions.
> The following example I find is for .html page: how to adjust rule for both
> .html and .htm pages?
>
> Options +FollowSymlinks
> RewriteEngine on
> RewriteRule ^(.*)\.html$ $1.php [NC]
>
>
> thanks.
>

Wrong newsgroup. This one is for php. Try an apache newsgroup, such as
alt.apache.configuration.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: mod_rewrite rule question [message #173314 is a reply to message #173305] Sun, 03 April 2011 02:50 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Corvet)

> I need set a mod_rewrite rule to map incoming .html and .htm requests to the
> (new) real .php extensions.
> The following example I find is for .html page: how to adjust rule for both
> .html and .htm pages?
>
> Options +FollowSymlinks
> RewriteEngine on
> RewriteRule ^(.*)\.html$ $1.php [NC]

RewriteRule ^(.*)\.html?$ $1.php [NC]
^
Micha
Re: mod_rewrite rule question [message #173316 is a reply to message #173314] Sun, 03 April 2011 10:12 Go to previous messageGo to next message
Corvet is currently offline  Corvet
Messages: 4
Registered: April 2011
Karma: 0
Junior Member
"Michael Fesser" <netizen(at)gmx(dot)de> wrote in message
news:p1ofp69bhpom8td4kvlt1carubjaglndl3(at)mfesser(dot)de...
> .oO(Corvet)
>
>> I need set a mod_rewrite rule to map incoming .html and .htm requests to
the
>> (new) real .php extensions.
>> The following example I find is for .html page: how to adjust rule for
both
>> .html and .htm pages?
>>
>> Options +FollowSymlinks
>> RewriteEngine on
>> RewriteRule ^(.*)\.html$ $1.php [NC]
>
> RewriteRule ^(.*)\.html?$ $1.php [NC]
> ^
> Micha
------

thanks for input. I just find also, another method would be:

RewriteRule ^(.*)\.(.htm|.html)$ $1.php [NC]
Re: mod_rewrite rule question [message #173318 is a reply to message #173316] Sun, 03 April 2011 11:07 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 03-04-2011 12:12, Corvet wrote:
>
> "Michael Fesser" <netizen(at)gmx(dot)de> wrote in message
> news:p1ofp69bhpom8td4kvlt1carubjaglndl3(at)mfesser(dot)de...
>> .oO(Corvet)
>>
>>> I need set a mod_rewrite rule to map incoming .html and .htm requests to
> the
>>> (new) real .php extensions.
>>> The following example I find is for .html page: how to adjust rule for
> both
>>> .html and .htm pages?
>>>
>>> Options +FollowSymlinks
>>> RewriteEngine on
>>> RewriteRule ^(.*)\.html$ $1.php [NC]
>>
>> RewriteRule ^(.*)\.html?$ $1.php [NC]
>> ^
>> Micha
> ------
>
> thanks for input. I just find also, another method would be:
>
> RewriteRule ^(.*)\.(.htm|.html)$ $1.php [NC]
>

you do mean:
RewriteRule ^(.*)\.(htm|html)$ $1.php [NC]

;)

--
Luuk
Re: mod_rewrite rule question [message #173319 is a reply to message #173318] Sun, 03 April 2011 11:30 Go to previous messageGo to next message
Corvet is currently offline  Corvet
Messages: 4
Registered: April 2011
Karma: 0
Junior Member
"Luuk" wrote:

>> ------
>>
>> thanks for input. I just find also, another method would be:
>>
>> RewriteRule ^(.*)\.(.htm|.html)$ $1.php [NC]
>>
>
> you do mean:
> RewriteRule ^(.*)\.(htm|html)$ $1.php [NC]
>
> ;)
>
> --
> Luuk
----------

yes, extra dots probably can be omitted.


Corvet
Re: mod_rewrite rule question [message #173320 is a reply to message #173319] Sun, 03 April 2011 11:44 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 03-04-2011 13:30, Corvet wrote:
>
> "Luuk" wrote:
>
>>> ------
>>>
>>> thanks for input. I just find also, another method would be:
>>>
>>> RewriteRule ^(.*)\.(.htm|.html)$ $1.php [NC]
>>>
>>
>> you do mean:
>> RewriteRule ^(.*)\.(htm|html)$ $1.php [NC]
>>
>> ;)
>>
>> --
>> Luuk
> ----------
>
> yes, extra dots probably can be omitted.
>
>
> Corvet

no, the SHOULD be ommited

see: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
<quoot>
Some hints on the syntax of regular expressions:

Text:
. Any single character
Escaping:
\char escape the given char
</quoot>

Therefore:
\.(.html) will match a dot followed by any character followed by 'html'
\.(html) will match a dot followed by 'html'



--
Luuk
Re: mod_rewrite rule question [message #173326 is a reply to message #173320] Sun, 03 April 2011 13:04 Go to previous message
Corvet is currently offline  Corvet
Messages: 4
Registered: April 2011
Karma: 0
Junior Member
"Luuk" wrote:

>>>>
>>>> thanks for input. I just find also, another method would be:
>>>>
>>>> RewriteRule ^(.*)\.(.htm|.html)$ $1.php [NC]
>>>>
>>>
>>> you do mean:
>>> RewriteRule ^(.*)\.(htm|html)$ $1.php [NC]
>>>
>>> ;)
>>>
>>> --
>>> Luuk
>> ----------
>>
>> yes, extra dots probably can be omitted.
>>
>>
>> Corvet
>
> no, the SHOULD be ommited
>
> see: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
> <quoot>
> Some hints on the syntax of regular expressions:
>
> Text:
> . Any single character
> Escaping:
> \char escape the given char
> </quoot>
>
> Therefore:
> \.(.html) will match a dot followed by any character followed by 'html'
> \.(html) will match a dot followed by 'html'
>
>
-------

Thanks a lot. The regular expressions is something difficult :)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Posting and redirecting to remote script
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 08:16:04 GMT 2024

Total time taken to generate the page: 0.02524 seconds