Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirects

.htaccess apprently written correctly, doesn't work

         

RockyMtnHi

10:33 pm on Nov 10, 2008 (gmt 0)

10+ Year Member



I have look at many solutions for this, and it is simple but it still doesn't work, so here goes...

I am moving my .asp site to a Wordpress, Apache, PHP site. The temp location is http://192.168.219.62/~twoonet7. I want to redirect from all old URL's individually to their new php counterpart. Note that the old .asp files do not exist on this server. The end result of typing in:
http://192.168.219.62/~twoonet7/resources-web-design-web-development.asp
is a 404 error. Am I writing the .htaccess file wrong? Thanks for your help.

Here is how the .htaccess file looks right now:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~twoonet7/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~twoonet7/index.php [L]

# start 21st redirects
Redirect 301 /resources-web-design-web-development.asp http://192.168.219.62/~twoonet7/web-development-about-us/
</IfModule>

# END WordPress

[edited by: jdMorgan at 11:23 pm (utc) on Nov. 10, 2008]
[edit reason] Obscured identifiable URL [/edit]

jdMorgan

11:20 pm on Nov 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's be clear. What is the full URL to
  • this .htaccess file?
  • the old .asp pages?
  • new index.php file?

    In addition to getting the code right, it has to be in the right location.

    It's also not clear why you're mixing mod_alias and mod_rewrite directives, why the mod_alias directive is embedded in an <IfModule mod_rewrite.c> container, or why you are using RewriteBase, which is not usually needed.

    If you control the server --in other words, if it's an in-house server-- then you don't even need <IfModule> because you'll know whether mod_rewrite.c is installed or not -- The purpose of the <IfModule> container is to ensure that code inside the container will fail silently when code is copied from server to server if the module which interprets the code is not installed on a given server.

    Jim

  • RockyMtnHi

    12:28 am on Nov 11, 2008 (gmt 0)

    10+ Year Member



    The .htaccess file is at (root folder of the new host):
    [192.168.219.62...]

    The current (old) site and .asp pages are all at:
    http://www.example.com
    and are on a Windows IIS 6.0 host, but I am removing all of these pages, replacing them with others having completely new .php names created through Wordpress and moving hosting to new LAMP hosting for Wordpress.
    An example of an (old) existing file that I am testing is:
    http://www.example.com/resources-web-design-web-development.asp
    Note that this file exists and produces no errors because I haven't moved the site yet, I am in the process of constructing the new one and will change the DNS entries when it is done.

    The new site hosting is at:
    [192.168.219.62...]
    <snip>

    All of the code in the .htaccess file was created by Wordpress except for the following 2 lines, and they are the ones I am trying to get to work:
    # start 21st redirects
    Redirect 301 /resources-web-design-web-development.asp [192.168.219.62...]

    This is the link that fails to redirect:
    [192.168.219.62...]

    Does this help?

    [edited by: jdMorgan at 1:08 am (utc) on Nov. 11, 2008]
    [edit reason] Obscured identifying information [/edit]

    jdMorgan

    1:19 am on Nov 11, 2008 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    The problem may be that you (or your host) are apparently using Apache mod_userdir to support pre-DNS-setup work, the result of which is that funky "~user"-type URL structure. If so, then you'll need to include that "~twoonet7" in the RewriteRule pattern and the Redirect prefix, and use a RewriteBase of "/" (which is the default).

    The rule for using RewriteBase is... don't. If simple, straightforward rules fail, then look in the server error log, and if the failed URL is resolving to a filepath other than the DocumentRoot plus the requested URL-path, and there seems to be some part of the actual server filepath missing, then that missing path-part goes into RewriteBase.

    Jim