Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bencarter78@hotmail.com's avatar

Clicking on paginated link redirects to truncated url with XAMPP (I know, it sounds crazy to me too)

Hi all

I'm slowly losing the will trying to get a L5 application to run on my XAMPP server.

Just to give you an overview of my setup...

We have Windows Server 2008 which is running XAMPP v3.2.1. This is only accessible via our internal network.

I've just ported an app from L4 to L5 and am now getting ready to deploy.

Although I don't like the 'public' suffix to my url I have been unable to get rid of it using the set up I have to use so I've learned to live with it.

Everything seemed fine but I noticed when clicking through a paginated list of users to go to the second page however at the point it chopped the base url from the url it was trying to access and I have no idea why. It was trying to go to

10.2.70.18/myapp/public/users?page=2

And somehow it gets redirected to...

10.2.70.18/users?page=2

I'm just using the render method on the pagination object. It formats the html correctly but when clicking the link something is happening to cause it to do this.

Can anyone tell me what on earth is causing it to do that or any ideas what to try?

Thanks

0 likes
11 replies
Dave_Martin's avatar

In your Apache configuration file where is DocumentRoot pointing? If you have it pointing to the /public directory you should not be seeing or using public in your URLs. An example from my configuration:

    DocumentRoot "c:/var/www/testinglaravel5/public"
bencarter78@hotmail.com's avatar
DocumentRoot "C:/xampp/htdocs"

@Dave_Martin what I don't understand is this truncating of the url, I've never even heard of that before. I'm not even sure what part of my stack is causing it.

I've just noticed that if I add a setPath method on the Pagination object then it'll work but I want to understand why it's not working out of the box with my app's base url

bashy's avatar

Your links are probably /users?page=2 not /myapp/public/users?page=2.

One is relative, one is an absolute path. Do the above and set the document root in your web server vhost to your Laravel's public directory.

https://kb.iu.edu/d/abwp

bencarter78@hotmail.com's avatar

@bashy I'm not using vhosts.

I've just worked out what is happening (didn't notice it before) but I'm not sure how to solve it. My pagination links are

10.2.70.18/myapp/public/users/?page=2
// Notice the trailing slash before the page param

But if they were...

10.2.70.18/myapp/public/users?page=2

...then it works. I can't figure out how to get rid of the trailing slash. My url config in app.php is '10.2.70.18/myapp/public'

Any ideas?

beznez's avatar

Use setPath. You might have to use an absolute path, but I think a relative one will work as well.

$users->paginate($number_of_users);
$users->setPath('users');
bencarter78@hotmail.com's avatar

@beznez Thanks, I didn't want to use this as I have pagination all over my application and it seems a bit of a hack. I was reading this thread https://laracasts.com/discuss/channels/general-discussion/l5-pagination-url/ and I think I really need to step back and set up our server better.

I just never like the hassle or can be arsed with the 'our network blah blah blah' arguments I have with our IT department. Oh well here goes...

bashy's avatar

FYI, you're always using a vhost. I meant a single one for your app, it's much easier to develop with then...

Adding a new virtualhost is best. It doesn't take much doing to get it setup.

bencarter78@hotmail.com's avatar

@bashy, oh right I didn't know that. I've tried using Virtualhost before but could never get it to work with our setup. I need a connection to an Advantage Database Server which is internally hosted, we have internal IP addresses which apparently poses problems, me who really needs a server 101 lesson and a less than helpful (to me) IT department. It all equals a headache.

bencarter78@hotmail.com's avatar

Thanks @bashy . I've followed those steps and have this in my httpd-vhosts.conf

<VirtualHost 10.2.70.6/myapp>
    ServerAdmin admin@localhost.com
    DocumentRoot "C:/xampp/htdocs/myapp/public"
    ServerName 10.2.70.6/myapp
    ServerAlias 10.2.70.6/myapp
    <Directory "C:/xampp/htdocs/myapp">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

What I'm not getting is how I can use this for an internally hosted server. The internal IP of the server is http://10.2.70.6 but I don't understand how I can use VirtualHost within this set up.

bashy's avatar

ServerName would equal a custom domain you setup in your local DNS (hosts file). You won't need a ServerAlias unless you want to add a www. domain there.

Do something like

ServerName someapp.dev
ServerAlias www.someapp.dev

Please or to participate in this conversation.