How to open files with extension removed?

#1

This link will not work unless I add .“php” to the end… How to I fix this for my client?

http://kicksmixbookstore.com/sitecake.php?scpage=featured

#2

Hi, i guess you are getting these links because you are using url rewriting on your server. Unfortunately Sitecake is not supporting url rewriting at the moment. There are some plans to integrate it in one of next releases.

#3

Hi, I managed to get this working with a with NGINX extenless rewrite, by adding a couple of lines to the sitecake source code.

I added a new attribute called “data-sc-href” to links, so Sitecake knows what file it should edit:

<a href="/contact-us" data-sc-href="contact-us.php">Contact us</a>

Then I added these lines to Draft.php (/src/Sitecake/Draft.php) at line 150 (before if (!Utils::isExternalNavLink($href) &&…)

$dataHref = $node->getAttribute('data-sc-href');
if (!empty($dataHref)) {
    $href = $dataHref;
}

What it does is just to use the “data-sc-href” if it exists instead of the “href” attribute.

I tested it briefly and it seems to work great. I know it not optimal editing the Sitecake source code, but I found no other way around this.

#4

Hi Marky,

thanks for sharing this. Nice approach. I’ll look into it and write some tests to make sure it doesn’t brake any other functionality. If all goes OK, we could add this to next release.

#5

That would be great,@predragleka!

#6

did this ever get implemented? there seems to be a lack of documentations on new releases and features / codes we can use. Since I’m running 2.8.7 there is no more draft.php file so where would I put this?

#7

@collab Hi, unfortunately, URL rewriting is still not implemented.