Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Enhancing a Simple PHP Application Cleaning URLs with Subfolders Moving the Other Pages

SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

Clean URLs with subfolders and SEO?

If we use this technique for having clean URLs, we end up with all files named "index.php".

Does this have a negative effect on SEO?

Thanks!

1 Answer

On a live site, this can usually be resolved using your .htaccess file on your server to resolve the index.php in your URLs. If you aren't comfortable editing your .htaccess or don't have access to it, you can contact your server company to resolve it.

SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

Thanks.

I'm still wondering if having all your files named "index.php" affects the SEO ranking.

There's no penalty as long as it isn't duplicate content, so you would be fine from an SEO standpoint unless you had badly formed redirects and showed "home.com/about" and "home.com/index.php/about". If Google is indexing both, you can technically work around this with rel=canonical, but you're better off just sticking with one to avoid duplicate content issues.

Another good thing to remember is that shorter URLs typically have higher click-through-rates, which has an effect on your ranking, so eliminating the index.php path could help with this (provided you have a unique, compelling meta description or unique content relevant to the user's search).

I'm sorry I wasn't as clear to your question in my initial response! The thing with SEO is that you'll want to remember that user experience and content are ultimately king. High quality, unique content with poorly defined URLs can still outrank well-created sites, but it isn't as common. Sticking to best user experience practices will just help keep your SEO consistent in the long run.