Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

.htacces for rewriting urls problem

New Here ,
Nov 11, 2007 Nov 11, 2007

Copy link to clipboard

Copied

Hi,

I'm using an .htacces files for rewriting my URLs e.g:
  • www.host.com/index.php?cat=1&id=7
    will be writtin as
  • www.host.com/index/cars/porsche

    This is the .htacces code I'm using:
    <Files index>
    ForceType application/x-httpd-php
    </Files>

    Doing this forces me to delete the extensions of my php files, but now DW CS3 can't read them anymore (not by double clicking on the file that is). Is there way to avoid this or is there a better way using .htacces to achieve this?

    Regards,
    Nick
TOPICS
Server side applications

Views

321
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 11, 2007 Nov 11, 2007

Copy link to clipboard

Copied

"nickBND" <webforumsuser@macromedia.com> wrote in message
news:fh6sfr$fjl$1@forums.macromedia.com...
> Hi,
>
> I'm using an .htacces files for rewriting my URLs e.g:
>
  • www.host.com/index.php?cat=1&id=7
    > will be writtin as
    >
  • www.host.com/index/cars/porsche
    >
    > This is the .htacces code I'm using:
    > <Files index>
    > ForceType application/x-httpd-php
    > </Files>
    >
    > Doing this forces me to delete the extensions of my php files, but now DW
    > CS3
    > can't read them anymore (not by double clicking on the file that is). Is
    > there
    > way to avoid this or is there a better way using .htacces to achieve this?
    >
    > Regards,
    > Nick

    <rant>
    Why is everybody so intent on not following file extension conventions?
    These were invented long ago for a purpose: so that the type of file can be
    obtained by looking at it's name, without opening the file to see what's in
    it.
    </rant>

    If you want to let users access these files without entering an extension
    rewrite url's without an extension accordingly

    # not a file
    RewriteCond %{REQUEST_FILENAME} !-f
    #not a directory
    RewriteCond %{REQUEST_FILENAME} !-d
    #capture url and rewrite with extension , append querystring and end
    rewriting
    RewriteRule ^(.*)$ /$1.php [QSA,L]

    --
    Joris van Lier


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 12, 2007 Nov 12, 2007

Copy link to clipboard

Copied

LATEST
Joris van Lier wrote:
> <rant>
> Why is everybody so intent on not following file extension conventions?
> These were invented long ago for a purpose: so that the type of file can
> be obtained by looking at it's name, without opening the file to see
> what's in it.
> </rant>

SEO optimization, somewhere someone either figured out or decided that a
folder/file path with proper search terms in them, /cars/nissan/altima
beats /index.php?id=3 for ranking and placement in the results of a
search. Blame Google.

Paul Davis
http://www.kaosweaver.com/
Visit us for dozens of useful Dreamweaver Extensions.

http://www.communitymx.com/
Partner at Community MX - Extend your knowledge

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines