jimfog
-
Posts
1,803 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by jimfog
-
-
What happens when you open the URL to the Javascript file directly in your browser?
It seems you're using relative URLs ( "js/jquery-1.11.1.min.js" ), your script tags should be relative to the site root so that they will open no matter what section of the site you're on. You can do that by prepending a slash to the URL ("/js/jquery-1.11.1.min.js")
yes I am using relative URL's...I tried prepending a slash,as you said but for all the JS files I get 404 in the console.
-
You can use the same RewriteRule directive you're currently using, but by preceding it with those RewriteCond directives you'll make sure it doesn't apply the rule to URLs that point directly at existing files or folders on the site.
I have come to understand what the problem is.This is my htaccess now...with all the changes suggested:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^blog_show/(.*)$ blog_show.php/?t=$1 [NC,L]
The problem persists though...
-
In your htaccess file, always make sure the URL is not of an existing file or directory.
You would add RewriteCond statements before your RewriteRule statement.
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
Ι do not understand.
First of all what these RewriteCond statements do?
You also say that the URL is not of an existing file/dir.
If that is the case how the rewrite rule must be....if not of an existing file/dir?
Cause you say also that there must be a rewriteRule statement.
-
The head section in one of my webpages has links to various JS files/plugins:
<script src="js/jquery-1.11.1.min.js" ></script> <script src="js/jquery.validate.js" ></script> <script src="js/jquery-ui 1.11.2.js"></script> <script src="js/jquery.bootpag.min.js" ></script> <script src="js/footer.js" ></script> <script src="js/html-inspector.js" ></script>
All the above in the following page:http://localhost/Appointments/Frontend/blog_show.php
In my htaccess file I have this rule:
RewriteRule ^blog_show/(.*)$ blog_show.php/?t=$1 [NC,L]
So rewriting takes place when the user types this in the web address bar:
http://localhost/Appointments/Frontend/blog_show/2016-07-28/
blog_show.php is called again but with a query string and here the problem appears.The js files/plugins do not load correctly...the console emit this error:I do not have the slightest idea why this happens... -
That Taxibeat site uses a different method, when they save their article part of the data is a URL stub which is used in the URL, so the htaccess rule passes that stub to a PHP script which looks up the article based on the stub. The stubs would be unique in the database.
At last we have arrived at the most important part of the topic.
So,you are saying that a URL stub is stored in the database.
If that stub comprises of the date and the title,then this is exactly what I intend to do.
Everything else you mention about an htaccess rule pointing to a PHP script that will "grab" the stub is precisely what I am doing here.
If the above is indeed the case I do not see how my approach is wrong.
In my case,also, the stub is the date and the title.Combining these two, an article may be uniquely identified.
I mean how possible is the case that tho articles have the same date and title.
-
You only want to support one article per day? That's an odd constraint to put on a system. This is why we use unique IDs instead of assuming that some other value will be unique.
Τhe user will be able to see only one full article at a time...I do not see how this is a constraint.
Exactly in the way it is done here https://taxibeat.com/blog/.
-
Ι think that a good alternative to ID is the date...I am going to use this for uniquely identifying a blog article.
-
...the example i gave and the link you went to.
what example?
Sorry...I am just a little confused,many posts for this topic.
-
Security, no because its rewritten to hide the id you will only use the friendly URL,...
The ID is hidden in the browser address bar but what about the HTML..the href tag?
The link the user is about to click.
-
The example has already been given, FIRST you produce the link that GIVES you the ID in querystring, RIGHT! this is the URL WITH ID you want to use, you then use mod rewrite to change the URL in address bar to a more friendly URL, so every time you use this URL it will STILL refer to the original URL WITH.... NOW sit down because this is going to blow your mind, READY i'm sooo excited about this!.... THE SAME querystring with the SAME value, meaning, if you use $_GET['ID']; you will STILL get the VALUE associated that passed querystring name of id. AMAZING isn't it... NEW URL no querystring, but still able to retrieve id value! MAGIC!
let me comment on the above...
You saying that the URL in the link will have an ID and then this will be converted to a friendly URL.I got that...
But the ID is exposed in the HTML source...isn't that a security vulnerability?
(The idea for a friendly URL from the beginning(with no IDs) as I said I got it from here https://taxibeat.com/)
Now one last thing....as I understand if we have two links about a corresponding number of blog posts...both of these will have corresponding IDs.
Yes but dont'we need a different rewrite rule for every article/ugly URL in htaccess?
You had answered no...well give me example how one rewrite rule can cover every possible different link(with different IDs each) .
-
You need to include id value as querystring in links, use mod rewrite to give friendly URL but STILL! give you access to retrieve id value to show article. The title SHOULD be stored as part of specific article in database, its just a title and should NOT be used to target that specific article because it has a potential to be used again within another pages title and you would need to filter to target the article you were specifically targeting, with id you do not have such a problem.
ALWAYS think long term.
Οk I got your point...nonetheless you must give me an example of how a friendly URL can lead to an URL with an ID.
Theory is good but an example would be better.
-
anyway...you are proposing to use an ID.
I still cannot understand how to associate a unique title with an ID.
You have to give me an example.
-
That is impractical you should look for id, that is specific for specific article, if you search for that title for a specific article you would have to allow for combinations that may include that title.
if ingolme is correct then there is no need for an ID.Just take a look at ingol,mes post.
-
just take a read more links here https://taxibeat.com/blog/ ...they are friendly either way(if you look at the HTML source)
I just want to rewrite it to an ugly form like the one ingolme mentions in post 44...and then based on the title retrieve the article from the database.
I will not use an ID as an identifier,there is no need for it,just the title.
At least this option seems viable...
-
here is the friendly URL now of a blog post:
http://localhost/Appointments/Frontend/blog_dtl/genga.php
The above is what the user sees in the address bar....I want the above to be rewritten in
http://localhost/Appointments/Frontend/blog_dtl/t=genga.php
...so I can grab genga(which is the title of the article) and based on it retrieve the article from the Database.
That is the rationale here...I do not know what kind of rewrite rule would that here.
-
What a lot of content management systems do is just rewrite the URL so that the entire URI is a single parameter, like this:
This URL:
www.example.com/data1/data2/data3
is rewritten to:
www.example.com/?q=data1/data2/data3
Then you can use PHP to separate parameters:
$parameters = explode('/', $_GET['q']); echo $parameters[0]; // Shows "data1"
Ok I need some help with it....how am I going to achieve that?
It must not be difficult.
-
What a lot of content management systems do is just rewrite the URL so that the entire URI is a single parameter, like this:
This URL:
www.example.com/data1/data2/data3
is rewritten to:
www.example.com/?q=data1/data2/data3
Then you can use PHP to separate parameters:
$parameters = explode('/', $_GET['q']); echo $parameters[0]; // Shows "data1"
hhhhmm...that is very interesting and probably the solution to my problem.
-
I got it.
And now here is the important conclusion.
Since my intention is to have friendly URLs which lead ti ugly with an ID(so I can retrieve the blog article from the DB)....that means one thing:
Making an entry in htaccess for every blog article....impractical....necessary though.
Is my above thought correct?
-
Notice how the h1 to h3 header titles STILL take the values from the querystring.
Where are you referring to?
-
all these are good but I have not figured out how they fit in my case:
A friendly URL link of a blog post that leads to a URL with an ID based on which I will search the db for the blog article.
Of course the friendly URL is always shown in the address bar....but somehow this must lead to a page where I can process the ID.
To be honest....I do not know even if that is possible the way I describe it.
-
what exactly are you trying to achieve in post 13 Dsonesuk?
-
Which is the same test i mentioned in my example. So are back on mod rewrite redirect or non mod rewrite redirect?
mod rewrite...
From the beginning this was the goal...and still is.
-
believe it or not...I finally made it working.I followed this tutorial http://dk.co.nz/seo
I implemented a rewrite rule...now I want to test the redirection also.
-
To use
Redirect 301 /blog_dtl/genga.php http://www.example.org/newpage.html
It must be in a .htaccess file in your root directory, it wll pick up any link that ends with '/blog_dtl/genga.php' and redirect to 'http://www.example.org/newpage.html' and mark it as a permanent redirect (301) meaning users and search engine will update to new url.
again...where is the roor dir from the folders depicted in the image?
My progect files are located inside Appointments and from there other directories are found...frontend for instance is inside of it.
read more links...blog posts
in PHP
Posted
Is there any other way to grab the stub besides a htaccess rewriting?Htaccess is a mess.