Skip to main content
Participant
November 11, 2007
Question

.htacces for rewriting urls problem

  • November 11, 2007
  • 2 replies
  • 345 views
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
This topic has been closed for replies.

2 replies

Inspiring
November 12, 2007
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
Inspiring
November 11, 2007
"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