1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

Discussion in 'Apache' started by Nintendo, Jul 30, 2005.

  1. Michaels-r

    Michaels-r Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #821
    I am having trouble getting a 301 redirect to work with a space in the original URL. I seem to get internal server errors whatever I try... The address I am redirecting is:
    http://www.steinbeck-reeves.co.uk/Bathrooms.html changefreq=monthly priority=1.0
    Code (markup):
    What I really want to do is strip off the space and everything afterwards for all addresses where there is a space and following parameters. I read that a space should be entered as \s - is that correct?

    This all came about when Google appeared to misread a sitemap file and seems to be taking forever to forget the old one.

    Thanks,

    Michael
     
    Michaels-r, Sep 11, 2008 IP
  2. antiguru

    antiguru Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #822
    I'm having an issue with mod_rewrite as well... not sure if this is possible to even do but....

    I have dynamically created links on my site that link to

    /blog/TXX/ (where XX is a number)


    I want them to pull data from /blog/index.php/TXX/

    While still displaying the shorter URL.

    So far I've got:
    RewriteRule /blog/T(.*)/ /blog/index\.php/T$1/ [R=301,NC]

    which brings up the correct data,and

    RewriteRule /blog/index\.php/T(.*)/ /blog/T$1/ [R=301,L]

    to try and re-form the URL as the short version but it understandably creates an endless loop.

    And yes I've tried to just re-make the dynamic page links, but it's not working yet =p

    Thanks htaccess masters!
     
    antiguru, Sep 29, 2008 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #823
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^blog/T([^.]+)/$ blog/index.php/T$1/ [L]

    R=301 is only for redirecting from one URL to another URL, not for the changing the URL part.
     
    Nintendo, Sep 29, 2008 IP
  4. datatrond

    datatrond Active Member

    Messages:
    213
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #824
    I just posted a question at http://forums.digitalpoint.com/showthread.php?p=9737003#post9737003 where I ask how I may permanent redirect a not working URL from one domain name to another domain name with another URL?

    I have about 5 URL's that is important enough to do this since the URL's are at the first page of Google And generates a lot of money.

    At the moment the new URL is located at page 8.

    I would like the URL: http://www.aktivfritid-shop.no/kategori.asp?maingroup=02 Tredemøller&bid=1

    To be 301 permanently redirected to: http://www.aktivshop.no/epages/Akti...ectPath=/Shops/Aktiv_Fritid/Categories/10/100

    Is this possible in the .htaccess file?
    Any idea on how I might do this?
    We are loosing valuable traffic at the moment and must react fast!

    I appreciate all the help I may get!
     
    datatrond, Nov 7, 2008 IP
  5. thundercow

    thundercow Well-Known Member

    Messages:
    246
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    108
    #825
    This thread is about the best explanation of mod rewrite I could find. Being me, however, I couldn't get it to work for me. Everything I did yields and Internal Server Error.

    Then, I tried simply pasting one or two of your samples from the original post, and I still get an ISE.

    Any ideas?
     
    thundercow, Nov 7, 2008 IP
  6. ThoRaK

    ThoRaK Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #826
    nice tut...TX for that :);):D
     
    ThoRaK, Nov 8, 2008 IP
  7. JackHeskett

    JackHeskett Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #827
    Thank you, I'm going to bookmark this thread for future reference :D
     
    JackHeskett, Nov 8, 2008 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #828
    *cough*Post original URL's and how you want them. *cough*

    The examples won't work as posted unless you have the exact same file name info. Missing a \ can also cause the ISE message.
     
    Nintendo, Nov 10, 2008 IP
  9. Rashy

    Rashy Peon

    Messages:
    20
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #829
    Thanks for this nice FAQ... The problem that i had earlier has been solved by vishwaa
     
    Rashy, Nov 10, 2008 IP
  10. proxywhereabouts

    proxywhereabouts Notable Member

    Messages:
    4,027
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    200
    #830
    Anyone can help me with this??

    I want to cloak a link on my site. Let's say I have http://www.theoriginal.com/purchase.php?signupid=1

    I want to show on the site as http://www.theoriginal.com and when a user click on this link, it will use the first link above.

    Is this correct?

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?theoriginal\.com$ [NC]
    RewriteRule ^(.*)$ http://www.theoriginal.com/purchase.php?signupid=1 [R,L]
    PHP:

    Please help.
    Basically I want to turn domain.com to domain.com/another_sublink.php





    PLUS ANOTHER.

    I just created a CGI proxy. I wanted to make the script run only when the submitted it was originated from the site, meaning I want to block direct type in of the url to access the proxy.

    Anyone can help?

    Thank you.
     
    proxywhereabouts, Nov 12, 2008 IP
  11. Emmy18

    Emmy18 Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #831
    what a big post,if it were in small sections,that might be easy to understand for all.
     
    Emmy18, Nov 14, 2008 IP
  12. kenbrower

    kenbrower Well-Known Member

    Messages:
    574
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    120
    #832
    Like most miva owners, I have a module which rewrites the categories for seo purposes, and modifies the htaccess :

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !-s
    RewriteRule ^page/(.*) /Merchant2/merchant.mvc?page=$1

    But because of miva not allowing a subcategory to belong to 2 different categories, I have some duplicate categories which I'd like to have one redirect to the other.

    I tried : redirect 301 /page/C/CTGY/ES_ES http://www.condomman.com/page/C/CTGY/Durex-Extra-Sensitive

    and also : RewriteRule ^page/C/CTGY/ES_ES(.*)$ http://www.condomman.com/page/C/CTGY/Durex-Extra-Sensitive
    /$1 [R=301,L]

    but neither worked because it interfered with the code already in place.

    Any suggestions? I just need to 301 redirect a few categories to their duplicate counterparts (in the above example : www.condomman.com/page/C/CTGY/ES_ES to http://www.condomman.com/page/C/CTGY/Durex-Extra-Sensitive) , but the preceding code keeps interfering with it.
     
    kenbrower, Nov 16, 2008 IP
  13. Simon

    Simon Peon

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #833
    I also need to escape spaces in filenames.

    I've inherited a site wit spaces in the filenames. I've recoded the whole site but need to redirect the old pages to new.

    Please tell me how to rewrite the following so the spaces don't cause trouble.

    RewriteRule ^/Ngai Tahu Whanui/Natural Environment/Customary Fisheries/Regulations http://www.ngaitahu.iwi.nz/Ngai-Tahu-Whanui/Natural-Environment/Customary-Fisheries/

    Been looking all morning for a solution, there must be others looking for the same.

    help appreciated,
    thanks in advance,
    Simon.
     
    Simon, Nov 17, 2008 IP
  14. susanqy

    susanqy Guest

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #834
    good post ,i will visit your website! but the post is too long
     
    susanqy, Nov 18, 2008 IP
  15. vinpkl

    vinpkl Active Member

    Messages:
    899
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #835
    hi

    i have my url as
    
    http://localhost/vineet/products.php?dealer_id=12&category_id=2 
    
    Code (markup):
    i read your tutorial and created my htaccess file

    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^products/(.*)/(.*)\.html$ /products.php?dealer_id=$1&category_id=$2 [L]
    
    Code (markup):
    but when i type in my browser
    
    http://localhost/vineet/products/dealer_id/12/category_id/2 
    
    Code (markup):
    or
    
    http://localhost/vineet/products/dealer_id/12/category_id/2.html 
    
    Code (markup):
    i get 404 error. object not found

    vineet
     
    vinpkl, Dec 12, 2008 IP
  16. tenthletter

    tenthletter Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #836
    That great work , and I hope you may contact me ,for any other web design or software development work. thanks ari

    www.irachtech.com, , +94773865730
     
    tenthletter, Dec 15, 2008 IP
  17. ThoRaK

    ThoRaK Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #837
    I'm trying to do something la this:
    when somebody type: www.anynamehere.mywebsite.com or just anynamehere.mywebsite.com to redirect him to www.mywebsite.com/myfolder but in adress bar to see just www.anynamehere.mywebsite.com without myfolder

    i have this code in my htaccess, but he seems not work:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} [a-z]+\.mywebsite\.com
    RewriteRule (.*) myfolder/$1
     
    ThoRaK, Dec 24, 2008 IP
  18. Jordan Garn

    Jordan Garn Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #838
    I've got an interesting problem I got mod re-write working on my server with regular PHP files, but for my main website i'm using Joomla, Joomla already uses mod-rewrite for SEO friendly URL's but I've done some custom PHP where I use the GET command to pass some variables. I tried changing the already modded URL which looks like this:

    http://domain.com/page-name.html?var=value value
    My Variable has a space in it's value

    like so:

    RewriteRule ^page-name/value-value$ page-name.html?var=value value

    Like I said, doing that worked for a regular PHP file on the server but not when I tried it in Joomla, (Joomla uses a htaccess.txt file, I can't find the regular .htaccess file on the server) Thanks for any help

    Jordan
     
    Jordan Garn, Jan 3, 2009 IP
  19. wservers

    wservers Peon

    Messages:
    289
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #839
    I have a similar issue:

    I moved my site to Wordpress and I have some Search Engine listings i need to redirect. How do I redirect a page like domain.com/some-page.php to domain.com/some-page/

    I can't find anything on it. Would I need to modify my .htaccess file or edit my permalink structure so somehow so I can create .php pages?

    Thanks!!
     
    wservers, Jan 26, 2009 IP
  20. darktick13

    darktick13 Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #840
    ok i'm having a problem... could someone help me please?
    I host with godaddy and they say that all of their linux hosting servers have mod_rewrite already installed and turned on. the website i'm trying to rewrite is musicmerchandiseonline . com

    here is the code

    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^bands/(.*)/(.*)\.html$ index.php?bands=$1&content=$2 [L]
    Code (markup):
     
    darktick13, Feb 20, 2009 IP