Jump to content

read more links...blog posts


jimfog

Recommended Posts

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

This is mod rewrite code

 

RewriteRule ^/?test.html$ test.php [L]
I don't know where you got the redirect 301 from?

 

let me clarify some things....

the redirect command is NOT from you....I found it in the web to make some testing.

and inside the htaccess file it is only this and ONLY this...I have removed your code.

 

Are we OK now?

As I said it is for testing purposes...and later on I will examine the rewrite case.

Link to comment
Share on other sites

Well if you kept to the same subject, and not go off on another tangent, but! Not quite another tangent cause you have remnants of the previous subject, we would know where we are, wouldn't we.

Edited by dsonesuk
Link to comment
Share on other sites

Well if you kept to the same subject, and not go off on another tangent, but! Not quite another tangent cause you have remnants of the previous subject, we would know where we are, wouldn't we.

yes you are right...when you mentioned about testing test.html.php....at that point I Misunderstood.

So,now here we are...I hope we can get a solution here.

Link to comment
Share on other sites

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?

the image:https://onedrive.live.com/redir?resid=BE27434B2AAC8130!454&authkey=!AO71ww8Tkksk6hc&v=3&ithint=photo%2cPNG

 

My progect files are located inside Appointments and from there other directories are found...frontend for instance is inside of it.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Depending your local or host setup the root directory is the main directory where folders/files related to website begin that separate it from other main website folders, you only want to target that level and sub folders levels that maybe referenced within the redirect statement, placing outside that level if available would target the url path of all existing website root folders.

 

Since the redirect statments target using /path/file.xxx if you target images folder which is norm name where images are placed you would be targeting all website folders with subfolder of images.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

what exactly are you trying to achieve in post 13 Dsonesuk?

Link to comment
Share on other sites

The first part

 

RewriteRule ^/?test.html$ test.php [L]

 

Allows you to check rewrite works

 

Note usually this would target the index.php of cms, this however targets a specific page (page1.php) with no, or with specific 3 querystrings used.

 

It looks at ugly URL with querystrings "http://localhost/web_testing/page1.php?country=USA&state=California&city=San_Diego" and convert to a more friendly URL " "http://localhost/web_testing/USA/California/San_Diego" while still accessing the original ugly URL in background.

 

So now ugly equals not so ugly, BUT! its is set only for ugly URL, you have to set it up to act on anyone using the new URL as well! You do this by redirecting using the ugly link, but doing so you will create a loop going from one to the other that is why you use a 'noredirect' query string so once the rewrite to open page and show clean URL is completed it is not allowed to proceed further and so ends.

 

It will also look for page1.php with any querystrings at all and add its own "page1.php?country=No&state=Where&city=Land [R=301,L]" or you can just return to specific page like the home page instead.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

The point is it does not matter! the id etc always exist for processing to take place, It is only the way the URL is shown in address bar that is changed. Notice how the h1 to h3 header titles STILL take the values from the querystring.

 

This is! as I said, a rough example on how to use mod rewrite to take an ugly querystring based URL and turn it into a more friendly URL, this is similar to how wordpress, joomla produce friendly URL's, The menus uses table of stored id/sub id ref/s to different content, which include type of layout etc to a produce page, this is only a small example on how you can use mod rewrite.

 

But! like you said yours is not CMS but you should be able to get an insight in how to use it for your website setup.

Link to comment
Share on other sites

Notice how the h1 to h3 header titles STILL take the values from the querystring.

 

Where are you referring to?

Link to comment
Share on other sites

Sorry! misread

this part

<?php echo '<h1>' . $_GET['country'] . '</h1>'; echo '<h2>' . $_GET['state'] . '</h2>'; echo '<h3>' . $_GET['city'] . '</h3>'; ?> 

So you can still retrieve these values passed on from the new URL because whatever you set the new URL to look like it will always refer to page1.php?country=USA&state=California&city=San_Diego or whatever values set and passed with it, at the time.

Edited by dsonesuk
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

No! The idea is make mod rewrite look for a specific pattern produced by blog querystring so that one rewrite line of code will do all.

 

You can add extra querystring values from actual post like date separated by day, month, year, so

anything that is saved with post can be used in querystring, a hidden field with 'jimfog-blog-post' for instance mod rewrite use this to identify a pattern OR add '/jimfog-blog-post/‘ directly to the URL and produce a friendly URL to your requirements.

 

YOU have to identfy what you can use from post in blog OR add to URL to produce friendly URL.

Link to comment
Share on other sites

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"
Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

 

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.

Edited by jimfog
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...