htaccess problem - duplicated in links (Win7) 1.7.3 [SOLVED]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

htaccess problem - duplicated in links (Win7) 1.7.3 [SOLVED]

Postby TRolandB » 03. December 2011 22:53

I migrated a wordpress site to xampp using the same steps I have successfully used on two other sites:

1) Changed the site url option in the database to http://localhost/sitename.com/
2) Changed permalinks structure to default

But when links on the local site were clicked parts of the urls were duplicated. For example this link (as it is in source view for the index page, with sitename.com replacing my site's name):

http://localhost/sitename.com/?page_id=129

when clicked, took me to:

http://localhost/sitename.com/localhost/sitename.com/?page_id=129

Which just returned me to the xampp landing page. My .htaccess file looked like this:

Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


Any ideas as to what was causing this and how I can fix it? I have applied a fix by changing the second RewriteRule line in .htaccess to:

Code: Select all
RewriteRule . /sitename.com/index.php [L]


Now the links do work, although the address is now:

http://localhost/sitename.com/localhost/sitename.com/localhost/sitename.com/localhost/sitename.com/localhost/sitename.com/?page_id=129

Even stranger! So while it seems to be working the url generated above is obviously not ideal. Disabling mod_rewrite stops the links working at all, and getting rid of the first RewriteRule line cuts down the number of duplications to 2, and the links still work. However I don't have much understanding of the htaccess file, I'm just trying things at random.

All help appreciated. Thanks,

Will
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby Sharley » 03. December 2011 23:52

Perhaps the RewriteBase / should be RewriteBase /sitename.com if that is the name of the folder.

RewriteBase / = htdocs folder
RewriteBase /sitename.com = htdocs/sitename.com folder

Change the sitename.com to what ever folder name you are using.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby TRolandB » 04. December 2011 00:30

Hey Sharley, thanks for the reply. Tried this but it didn't seem to have an effect. Just noticed two more strange things:

1) Whenever I change the permalinks structure away from default in wp-admin, a new htaccess file is created in the c: directory, where xampp is located, identical to the one above, except for RewriteBase being localhost/sitename.com/, and the 2nd RewriteRule being . localhost/sitename.com/index.php [L]. This causes an apache internal server error so I have to delete it. (The file is still created in the same directory when I change htaccess as you suggest above.)
2) Each time I click on a new link in the site another localhost/sitename.com/ is added to the URL in the address bar!

This is very strange.
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby Sharley » 04. December 2011 00:39

Being as you are in experiment mode :) try commenting out the RewriteBase line so it is not being used - add a # space to the start of the line.

Server 500 errors are best investigate by reading the \xampp\apache\logs\error.log file.

If WP is creating the .htaccess for permalinks then you need to check and double check that all the paths are correct in WP as you seem to be involved in ReWrite looping.

Apache considers the / slash to be the server's DocumentRoot (htdocs and so http:// localhost) not the site folder.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby Sharley » 04. December 2011 00:50

One solution might be to delete or rename the index.php and index.html in the htdocs folder and put your WP folders and files directly into the htdocs folder so that when you type http://localhost your WP site will be shown in the browser - you would need to tell WP config about the path changes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby TRolandB » 04. December 2011 01:00

Haha yes well I'm certainly learning a lot about htaccess though experimentation. Could you tell me what the
Code: Select all
. /
means in the second rewrite rule? I'm not sure about the single dot, then the space. I'll reply with the other stuff in a moment.
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby TRolandB » 04. December 2011 01:06

Nothing changed though even when the RewriteBase line was commented out.

As for the server error, it is the presence of that newly generated htaccess file that causes it, although can't tell anymore about it than that.

Paths seem to be correct, under settings in admin I've got:

Wordpress address: http://localhost/sitename.com
Site address: localhost/sitename.com

And the siteurl option in the database is:

http://localhost/sitename.com/

Re: putting everything in htdocs, I kind of think I should try and fix it while keeping it in its directory, as if it happens again on another site I can't put that one there as well :wink:
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby Sharley » 04. December 2011 01:38

Site address: localhost/sitename.com
If that address refers to a folder path then there is no localhost folder so try just the path:
Site address: /sitename.com
Which equates to htdocs\sitename.com
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby TRolandB » 04. December 2011 02:32

Aha, thank you. Although changing it to /sitename.com didn't work, changing it to be the same as wordpress address did work.

That's great, now I can go to bed. Thanks again, and have a good day. I love the name of your town by the way.

Will
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby TRolandB » 04. December 2011 02:42

If you do happen to know what:

Code: Select all
. /


means in the second rewrite rule (why the single dot then the space before the slash?) I'd appreciate it, as it still confuses me.
TRolandB
 
Posts: 6
Joined: 03. December 2011 22:14
Operating System: Windows 7

Re: .htaccess problem - localhost/sitename/ duplicated in li

Postby Sharley » 04. December 2011 03:15

That is good news Will and thanks for the feedback. :)

I think these Google search results can answer your question better than I.

A good syntax reference here:
http://www.webforgers.net/mod-rewrite/m ... syntax.php

Basically it means it will hide the index.php in the URL.

So instead of displaying
http://localhost/sitename/index.php
it instead drops the index.php and displays
http://locahost/sitename/

Good explanation of your full rewrite section in the .htaccess file here:
http://dev-tricks.com/htaccess-rewriter ... -examples/


I will close this topic now as it appears that you solved it.

Sleep well and best wishes from sunny Yeppoon. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 26 guests