Jump to content

How to control URL best way?


Frangoo
 Share

Recommended Posts

Hi,

I am new to PW and first of all: Thanks to all the great hard work on it!! ;)

I created my first site, but I am having problems to find the correct way to arrange the URL.

My concret problem:

PW is running on server A in e.g. "/project/cms/site".

Domain is on server B, e.g. "my-domain.com".

On server B a .htaccess-file has already a reWrite-rule to point the user to server A to path "/project/cms".

That is giving now the user this URL in the browser: "www.my-domain.com/site/product/item-a".

Problem: I do not want to have the "site" - path in between :-(

Instead I want this:  "www.my-domain.com/product/item-a".

But where I need to do that? Did I already made a mistake in setting up my project? Do I need to hook a module?

I want a valid solution, no hack, so it works proper in all other modules (for links in the HTML Editor, for the images / assets, etc.).

I am very glad for any help :-)

Link to comment
Share on other sites

Hi Tom,

thanks for your answer! :)

I have to admit, that I am not a server-expert and do not know, what exactly "nameservers" means and will help in my case. Can you maybe help me up and explain that topic?

I have to comment, that I have no access to server A with the Domain. The customer wants me to host the pages on my server, and does not want to give away is domain.

Thank you,

Frangoo

Link to comment
Share on other sites

Hi Frangoo,

Nameservers decide where the DNS is hosted. The DNS is like a highway interchange with signs "www.domain.com" that lead to different exits. For example you can have "helpdesk.domain.com" go to a completely different server.

Changing the nameservers means you hold the DNS and you can decide where these exits go, in your case your server. As you may know servers all run off an IP this may look something like 192.168.0.1 all a domain does is mask that. For example www.domain.com = 192.168.0.1, helpdesk.domain.com = 192.168.0.2. 

In your case nameservers may not actually be the way to go because he may have emails hosted else where. These are known as MX records and they are part of the DNS. Changing DNS can get rid of these records and cause his emails to stop working. Scary I know. However it's not much a problem at all. 

What you need to do is let them host the DNS as normal, but change the "exit" to your server. To do this you need to login to where their domain is hosted, go to the DNS and change the A record "@" or "*" (These are root/wildcard records) to your server IP and change "www" to your server IP. 

This will give you the results you are after :) Actually messing around with the .htaccess file to do this is more complicated. 

  • Like 2
Link to comment
Share on other sites

Hi Tom,

thanks for that detailed answer!! *+1*

I got it :)

But before I go to bother my customer: Does it really help me with the problem of the showing browser-urls?

I can point the "exit" of DNS of course to my server, e.g. "my-domain.com/project/cms/", but than, if I understood it correct, I will still have the "site"-folder in my links of PW, right?

Plus the internal links and file-links will have the "site" as well....

arggh... I am confused :-S So sorry to bother you again!!

  • Like 1
Link to comment
Share on other sites

Hi Tom,

thanks for that detailed answer!! *+1*

I got it :)

But before I go to bother my customer: Does it really help me with the problem of the showing browser-urls?

I can point the "exit" of DNS of course to my server, e.g. "my-domain.com/project/cms/", but than, if I understood it correct, I will still have the "site"-folder in my links of PW, right?

Plus the internal links and file-links will have the "site" as well....

arggh... I am confused :-S So sorry to bother you again!!

You are not bothering us at all, we are here to help :) the htaccess file will deal with all that. I'm not too sure what you are doing in the htaccess file to redirect to your server, but it seems it's using the domains server htaccess file as you mentioned and not ProcessWires. 

Once you point it over to your server, it will start using yours. It's really important that you change htaccess.txt to .htaccess as that also offers a lot of security features. 

Link to comment
Share on other sites

The site folder should not show up in any urls besides if you put the whole processwire installation in such a folder. 

Hi,

I have the "/wire/"- folder next to the "/site/"- folder.

In "/site/" I just have the "/assets", "/templates" and "/modules" and the local site "config.php".

Seems to be fine for me, or do I have missed something?

Thanks in advance! :)

Frangoo

Link to comment
Share on other sites

Where is he hosting his domain name? Is he using cPanel, Plesk, etc.?

I do not know, and I am not sure if he will be able to find out :-S :D

That's fine, but those folders should never be part of an url (besides for assets), no matter how you configure the .htaccess.

Yes, I agree and there I wanna go :)

I never touched a .htaccess from PW, better said: I DO NOT have any .htaccess in my PW folders - maybe herin is the solution of my problem.

I will find out how it has to look like and investigate.

Link to comment
Share on other sites

ProcessWire doesn't work without an .htaccess file in the root folder.

I truely did not have any .htaccess- file in my PW folder, and it worked (at least the view).

And I found out what happened: To test the configurations, I copied my project into another folder, and doing this the .htaccess was not beeing copied >:(

Now I added it, and *hurray* my "site"-folder in the URL is gone :rolleyes:

Just testing if everything else works fine....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...