Forum Moderators: phranque

Message Too Old, No Replies

.htaccess problem - localhost/sitename/ duplicated in links

.htaccess problem - localhost/sitename/ duplicated in links

         

TRolandB

10:47 pm on Dec 3, 2011 (gmt 0)

10+ Year Member



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 [localhost ]
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):

[localhost ]
when clicked, took me to:

[localhost ]

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


# 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:


RewriteRule . /sitename.com/index.php [L]



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

[localhost ]

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

wilderness

10:59 pm on Dec 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to Webamster World

Forum charter [webmasterworld.com]

It is not appropriate to expect other members to write your code for you or to debug your entire project; Please don't expect other members to solve a problem you don't want to begin solving yourself.

Don't get upset if someone has the answer but wants to provide you with resources and material to help you solve it on your own. After all, the most educational threads are those where members learn how to help themselves. Such threads also prove to be of most value the next time someone has a similar question.

Before posting a new thread, please try looking through the older posts in the forum index. Someone may have recently asked the same question, and you may benefit from the posted answers. Using the WebmasterWorld search function or the site-specific search feature of major search engines may help you find exactly what you are looking for on WebmasterWorld.

Please describe your server environment and include whatever research and testing you've done so far. This will help the members who are willing to help you, and increase their number, too. Better, more-detailed questions get faster, better, and more-detailed answers, since the other members won't have to ask you for more information.

Please do not post specific details such as domain names, full IP addresses, or personally-identifiable information such as name, e-mail address, IM screen name, etc. Such specifics will be edited or removed in accordance with our Terms of Service [webmasterworld.com], which may render your post meaningless. Please replace all instances of your domain name with "example.com" before posting.

Please do not post links to "test page" URLs, tiny-URLs, screen-shot URLs, personal URLs, or commercial URLs of any nature. Generally, .edu and .org URLs are OK. We prefer to direct members to authoritative non-commercial resources in order to prevent any possible conflicts of interest. Furthermore, posted example links may quickly become outdated, rendering the thread useless to someone reading it just a few months from now. Verbalized problem descriptions will be useful for years to come.

"Fix my code" and "Do my homework for me" threads:

This is a discussion forum, not a help desk or a free code-writing service; If you have a problem, please try to research it and then phrase your post in a manner conducive to general discussion of the issue. Rather than providing one-off solutions, we prefer to help people find resources to help themselves.

A general guideline for code-related problems is: Post your own code and describe what you hoped it would accomplish. Then describe how it fails and include all relevant information from your server error logs. Too-general posts in the form of "What code do I use to do this?" often go unanswered for a long time.

The following resources are often referenced in our Apache forum, and may help to answer or focus your questions.

Webmaster World Search next to LOGIN

Forum Library [webmasterworld.com]

lucy24

11:49 pm on Dec 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Please replace all instances of your domain name with "example.com" before posting.

Reason that applies to entire WebmasterWorld forum: You should only post links to recognized authorities like apache or w3c-- or related WebmasterWorld threads-- and never, ever to your own site. (This is a terrific pain for me because I'm accustomed to using one corner of my site just to hold examples and screenshots for posting. Different rules here.)

More important reason that applies specifically to Apache subforum: The Forums software converts all links-- whether authorized or not-- into clickable autolinks.* This means we can no longer see what you typed. But we don't want to go to your site; we need to see what the original code said.

If you need to name more than one site, there are some equally safe variant forms:

http://www.example.com
http://example.com
http://www.example.org
http://example.org
http://www.example.net
http://example.net


* The software also expands the abbreviation "wmw" to "WebmasterWorld" unless you engage in deliberate hanky-panky to prevent it.

TRolandB

12:29 am on Dec 4, 2011 (gmt 0)

10+ Year Member



I'm not clear whether these replies are general info or you are saying I've done something wrong?

I have used sitename.com instead of example.com, but they serve the same purpose. And the links I posted were just to show the URLs, they don't lead anywhere.

TRolandB

1:39 am on Dec 4, 2011 (gmt 0)

10+ Year Member



Problem solved on another forum. Changing 'site address' in wordpress admin from localhost/sitename.com to [localhost...] fixed it.

I think this may have been because wordpress didn't accept the URL without http, rather than because http made apache act differently.

wilderness

3:54 am on Dec 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have used sitename.com instead of example.com, but they serve the same purpose.


More important reason that applies specifically to Apache subforum: The Forums software converts all links-- whether authorized or not-- into clickable autolinks.* This means we can no longer see what you typed.


using your sitename

[localhost ]

using example

localhost/example.com/

TRolandB

12:14 pm on Dec 4, 2011 (gmt 0)

10+ Year Member



Seemed to behave the same for me whether I used sitename.com or example.com - it was adding the http that generated the autolinks.

Anyway it's solved now as described above.

wilderness

4:51 pm on Dec 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Seemed to behave the same for me whether I used sitename.com or example.com - it was adding the http that generated the autolinks.


You just don't get it, nor do you care.
The syntax does not appear when an auto link takes place.

Anyway it's solved now as described above.


Typical of newbs that have failed to read and comply with the forum charter.

"Fix my problem and I don't care about the forum or the the other participants".

TRolandB

5:52 pm on Dec 4, 2011 (gmt 0)

10+ Year Member



Well Wilderness, if I post again I will of course use example.com. However all you need to do to see the URL, which is all I was trying to show, is to hover your mouse pointer over the link.

The reason I posted the solution was precisely because I DO care about the forum and the other participants. If I didn't I wouldn't have bothered.