SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Mod_rewrite and redirect with subdomain

    Hello,

    simply we tried use .htaccess redirect dynamic URL to virtual sub domain with same dynamic URL with this code

    RewriteCond %{HTTP_HOST} ^mysite\.net [NC]
    RewriteCond %{QUERY_STRING} ^link=(.+)$
    RewriteRule ^news\.php$ http://news.mysite.net/news.php?link=%1 [L,R=301]

    http://mysite.net/news.php?link=97 to http://news.mysite.net/news.php?link=97

    need help with 3 things

    1-.htaccess code redirect 301 all old links http://mysite.net/news.php?link=97 to http://news.mysite.net/97.html
    2-redirect 301 all old links http://mysite.net/news.php?link=97 to http://news.mysite.net/97.html
    3-virtual sub domain of http://news.mysite.net has its page not get index page as it happen now


    Thanks

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,607
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    meno,

    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, tYou might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    Now, the problem may be with how your subdomain is setup. Is it's DocumentRoot the news subdirectory of mysite.net? Is the DirectoryIndex of the news subdomain news.php? These answers are critical to answering your question.

    Caution: Redirect is a mod_alias directive while redirect is what mod_rewrite is capable of doing to a request. Please be sure to specify whether you're asking a mod_alias question or a mod_rewrite question (because I don't believe mod_alias can look at a query string, you need mod_rewrite).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    news sub domain is not founded
    but it's virtual sub domain by Mod_Rewrite
    this is answer of your question

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,607
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    meno,

    If the subdomain is "virtual," then it's not available to be linked to because it doesn't exist. For your redirection to work, you must establish the subdomain.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now we use virtual subdomain and can do this

    http://mysite.net/news.php?link=97 to http://news.mysite.net/news.php?link=97

    how we can do (without subdomain linked)

    1-.htaccess code redirect 301 all old links http://mysite.net/news.php?link=97 to http://news.mysite.net/97.html
    2-redirect 301 all old links http://mysite.net/news.php?link=97 to http://news.mysite.net/97.html


    thanks for replies

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,607
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    meno,

    Every subdomain is registered and is, in effect, another domain on the Internet. The only way to handle a request for a subdomain is to have it registered with your DNS (domain name server). If you do not do this, any redirection to unregistered_subdomain.example.com will fail to find the host. If it fails to find a host, it cannot be handled by your host (or by mod_rewrite).

    I suspect that you DO have news setup as a subdomain so I must repeat my question: What is the physical location of the DocumentRoot of the news subdomain?

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Tags for this Thread

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
  •