# Routing html extension SOLVED

**URL:** <https://discourse.slimframework.com/t/routing-html-extension-solved/1939>\
**Category:** Questions\
**Created:** [October 27, 2017, 4:53pm UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939 "2017-10-27T16:53:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![narven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/narven/32/517_2.png) [@narven](https://discourse.slimframework.com/u/narven)\
**Post date:** [October 27, 2017, 4:53pm UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/1 "2017-10-27T16:53:33Z")

</div>

Hi,

I used to have some routing setup on a server that had something like [someurl.com/panel.html](http://someurl.com/panel.html)

No i’ve converted all into Slim. What used to be inside of panel.html is inside of /panel route

My question is to know if is possible to redirect the route /panel.html to /panel using slim. I’ve tried a few options (including middleware) but did not work.

I know we can do it using htaccess or nginx/apache, but I dont have access to that.

Is there any proper way or using slim to do it?

thanks

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [October 27, 2017, 10:29pm UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/2 "2017-10-27T22:29:00Z")

</div>

Of course if you want to there is no reason why you can’t make the route `/panel.html` in Slim as well. But if `/panel` is still desired, you can do something like this.

```php
$app->get('/panel.html', function ($request, $response, $args) {
    return $response->withRedirect('/panel', 302);
});

```

Or alternatively:

```php
$app->get('/panel.html', function ($request, $response, $args) {
    return $response->withStatus(302)->withHeader('Location', 'http://example.com/panel');
});

```

Finally, even though you don’t have access to Apache, so long as you have the ability to use `.htaccess` files you could do the redirect there rather than within Slim.

---

<div class="post-metadata">

**Author:** ![narven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/narven/32/517_2.png) [@narven](https://discourse.slimframework.com/u/narven)\
**Post date:** [October 27, 2017, 11:44pm UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/3 "2017-10-27T23:44:39Z")

</div>

Hi, thanks for the fast reply.

I’m almost sure that you cannot do that, slim (v3) does not recognise the `.` In that case it will only get `/`. I think I’ve try that before, but I will give another shot.

thanks

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [October 28, 2017, 10:45am UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/4 "2017-10-28T10:45:53Z")

</div>

> [@narven](#):
>
> I’m almost sure that you cannot do that, slim (v3) does not recognise the . In that case it will only get /.

It works fine for me.

```php
$app->get('/panel.html', function ($request, $response, $args) {

```

---

<div class="post-metadata">

**Author:** ![narven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/narven/32/517_2.png) [@narven](https://discourse.slimframework.com/u/narven)\
**Post date:** [October 30, 2017, 9:47am UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/5 "2017-10-30T09:47:45Z")

</div>

I’ve tested today again… that does not work at all.

Having `/panel.html` just is the same has `/`

Need to find another way.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [October 30, 2017, 11:53am UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/6 "2017-10-30T11:53:33Z")

</div>

There is no reason why that shouldn’t work and it is fully supported in Slim. Show us some code (at least your route definition and any webserver routing) and we will have a look.

---

<div class="post-metadata">

**Author:** ![narven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/narven/32/517_2.png) [@narven](https://discourse.slimframework.com/u/narven)\
**Post date:** [October 30, 2017, 3:28pm UTC](https://discourse.slimframework.com/t/routing-html-extension-solved/1939/7 "2017-10-30T15:28:08Z")

</div>

Sry I was mistaken. In general works, but in my case I probably have some kind nginx configuration probably `index index.html index.php` that is not allowing it.

I tried redirecting with a different extension name `index.xxx` and it worked. I will have to come back to this later.

But thanks
