SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod Rewrite help needed!

    Hi,

    I am using Mod Rewrite accoss the whole of my site and I was wondering if it would be possible to do something with the following rewriterule so that when I type in something like: http://www.simplysearch4it.com/a00000/1.html it would then go to the http://www.simplysearch4it.com/artic...00000&a=1.html

    RewriteRule ^article/a(.*)/(.*).html article.php?b=$1&a=$2

    Is there any way of doing this?

    Thanks in advance.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteRule a(.*?)html article.php?b=$1&a=$2

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Redditch UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Help me also please after John.
    ~~~~~~~~~~~~~~~~~~~
    Can anyone alter this for me to include use of www. as well as no www. and also see how the whole thing could be tidied up and written correctly but with exact same results:
    ~~~~~~~~~
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
    RewriteCond %1 !^www$ [NC]
    RewriteRule ^.*$ /%1\.php [R,QSA]
    ~~~~~~~~~
    Thanks to anyone who can help.

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    john278

    (.*) is just too common for mod_rewrite. You have to be more specific in your expression, for example:

    RewriteRule article/a([0-9]+)/([^.]+) article.php?b=$1&a=$2

  5. #5
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Redditch UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello stereofrog
    ~~~~~~~~
    Any chance on help with above please?

    Thanks

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure what you're trying to do... maybe this?

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R,L]

  7. #7
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Redditch UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    explaining

    thanks
    ~~~~
    to try and explain: if the hostname is "mysub" or "www.mysub" then a file called "mysub.php" is then pointed to by the .htaccess file, but I have to have it working with or without www. But if neither then index.php is pointed to.

  8. #8
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Redditch UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    tried - but no good

    hello
    ~~~
    I tried what you said but with or without www. it points to index.php
    I have wildcard enabled but no access to conf file. The original file works ok but with no www and I hashed it together and I am new to this so it must be written wrong.

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by reminder
    Code:
    RewriteRule a(.*?)html article.php?b=$1&a=$2
    Thanks for your help, but the above Rewriterule didn't work for my site as it just gave most of my site an Internal Server Error whenever I use the Rewriterule that you gave me.

    I think is is because I have got quite a few more rules within the .htaccess file, which also starts with a.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •