It is possible  to use SEO friendly url to download files and in php includes?

altariamx2003 used Ask the Experts™
I got some questions about SEO friendly url's

1.-I was wondering if it is possible to use a SEO friendly url's to download a file, I mean usually to download a file most of us use url's like "", but I would like to know if it is posible to add a "rewriterule" in my .htaccess to use a SEO friendly url like "" to download the pdf file localted in the folder "pdf" and hide the real path of the file.

2.- ¿It is possible to use SEO url's with php includes?
In my code i got code like <?php include ("assets/principal.php"); ?>, but I wanna know if it is possible to add a "rewriterule" in my .htaccess to use a SEO friendly url to use includes like <?php include (""); ?>
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dr. KlahnPrincipal Software Engineer

What is meant / implied by the term "SEO friendly" links?  I have not heard of such a thing.

Search engines don't care what the URL in a link looks like, as long as it leads to real, useful content.


Hi Mr. Klahn when I mean "friendly links" (friendly url) its something like this

in my .htaccess I add this rule
RewriteRule ^industrias/([a-zA-Z0-9-/?=&]*)$ /oculto/industria.php?rID=$1 [L]

This allow me to use links like this: instead of

Sorry my english sucks i mean "friendly url"
Dr. KlahnPrincipal Software Engineer

The search engine doesn't care what the URL looks like.  All it wants to see is content where the URL points at.  The URL can be the most unreadable, scribbled up, obfuscated with hex characters thing you can imagine ... search engines do not care a bit.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.


Im gonna try to be more clear

Again sorry for my english

Question No. 1
As you know when we wanna add a downloadable file in a website we usually add a url like "http://www.myserver/pdf/myfile.pdf" as an example

I was wondering if it is exists a way to add a "rewriterule" in my .htaccess like RewriteRule ^mydownloads/([a-zA-Z0-9-/?=&]*)$ /hidden/mydownloads.php?rID=$1 [L] or something like that, that let me use url's like http://www.myserver/mydownloads/myfile to download some file in a hidden folder. The idea is to keep my real download folder in a secure and hide location path.
Question No. 2.
Currently to hide the real location of my JS files is Im using a "rewriterule" in my htaccess like: RewriteRule ^controls/(.*)$ /hiddenassets/controls/$1 [NC,L]. This rule allow me to add lines like:
            <script src="controls/folder1/jquery.appear.min.js"></script>
            <script src="controls/folder1/jquery.easing/jquery.easing.min.js"></script>
            <script src="controls/folder1/common/common.js"></script>

That rule allow me to keep all my JS files in a secure and hidden location.

I wanna know if there is a way to add a "rewriterule" in my .htaccess like RewriteRule ^myassets/([a-zA-Z0-9-/?=&]*)$ /hidden/myassets.php?rID=$1 [L] or something like that, that let me use "friendly url´s" in a php include's like  <?php include ("myassets/mycontrols"); ?>.

The main idea is to use the friendly url inside the php "include" to use a master php file to call my JS files (located in secure and hidden path).

Or if this is not possible i would like to know how to create a master JS file where i can Import all my JS files that my website will use

Best regards
Most Valuable Expert 2017
Distinguished Expert 2018

1. Yes - you can link any url to a download - you can link to a PDF. For example you could have the following rule in your .htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^something$ something.pdf [L,NC,QSA]

Open in new window

Alternatively you can route the request to a script that uses the readfile() and header() commands to send back the file

2. I cannot think of a single valid reason for why you would want to do this. Your script will never be seen by a spider - only what it outputs so why would you want to do this?


thx for answer Julian

1.- Thx for the advice, i made a rule and it works like a charm.

2.- Just to improve my code.
For example with the CSS files using the rewriterule RewriteRule ^controls/(.*)$ /hidden/$1 [NC,L] I use a master CSS file where I call all the css that im using in the current page

In the page i got: <link rel="stylesheet" href="/controls/principal.css">, and inside the file i got something like this:
@charset "utf-8";
/* CSS Document */
@import url(/controls/css/global.css);
@import url(/controls/css/webfont_global.css);

I like to handle my css like that because allow me to do a better code (I hope so).

I was wondering If it is possible to do the same for my JS files
Most Valuable Expert 2017
Distinguished Expert 2018
<?php include ("assets/principal.php"); ?>,
Is not the same as an import in CSS - the former happens on the server, while the latter in the browser.

I still can't think of why you would want to use an SEO friendly URL on a PHP include?

I was wondering If it is possible to do the same for my JS files
This is now a different question.

The idea is to reduce the number of roundtrips to the server. Modern web apps combine CSS into a single file - same with JS - and with JS they also do something called Tree Shaking to remove code that is not used.

If you are not using a build environment that uses webpack or similar then you can do this manually - in your JS files you would create a release JS file that comprises minified versions of your JS scripts in one file.

This is why there has been a move towards build environments that allow you to structure your code logically in the source but packs the files into optimized resources for distribution.


thx for your answer Julian, im gonna check about "tree shaking"

Thx a lot bro


thx to julian
Most Valuable Expert 2017
Distinguished Expert 2018

You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial