I am making one website about books and the user reaches the book which he/she intends by traversing though the subjects, then categories and then the subcategories.
As usual, I have made pages that use query strings like this
www.mywebsite.com/subjects.aspx?subjectid=10
The subjectid refers to one of the subjects.
The the user selected the categories and then subcategories and reaches the book.Now, everything is referred by it's id and not by it's name.
Now my question is that the Search Engines dont know how many subjeccts are there and the subject names are not understandable from the id(s).
When I tried to use Google Custom Search, and passed on the url of my website it does not go deep to the book level, instead stays on the main url www.mywebsite.com.
There are some website that I have seen have URL like this:
http://dotnetslackers.com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx
Do they really create a seperate aspx page for each and every article ?
I maynot be able to make you people understand what I want coz I just started asp.net so please think that it has got to do with SEO.
If any clarification is need, please comment and will edit the question.
EDIT 1: Just when I posted this question I noted that it has also created a similar type of page:
http://stackoverflow.com/questions/5581873/seo-layout-of-the-website
Now, Is that a new folder "seo-layout-of-the-website" !
EDIT:2 SO it appears that URL Rewriting is what I need. The example given in one tutorial states that for urls like :
http://www.store.com/products.aspx?category=books
http://www.store.com/products.aspx?category=DVDs
http://www.store.com/products.aspx?category=CDs
I can redirect them to
http://www.store.com/products.aspx/Books
http://www.store.com/products.aspx/DVDs
http://www.store.com/products.aspx/CDs
But in my case, I am using Ids, so does that mean that I should use the names (subject.aspx?subjectname=abcd instead of subject.aspx?subjectid=123) ?
URL Rewriting is what you're looking for. So you could convert your URL:
www.mywebsite.com/subjects.aspx?subjectid=10
to:
www.mywebsite.com/subject/10
by adding a route to it. If you're using ASP.NET 4, you can do this easily. In your Global.asax.cs file, define the following in the Application_Start function:
using System.Web.Routing;
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute(
"SubjectRoute",
"subject/{subjectId}",
"~/subjects.aspx"
);
}
And in subjects.aspx.cs, get the value with:
if (Page.RouteData.Values["subjectId"] != null)
{
var mySubjectId = Page.RouteData.Values["subjectId"].ToString());
}
No, they don't create new pages for SEO purpose. what most of us do is rewrite the URL rule in htaccess or apache files. I dont know how it works in asp though
Related
I am new at this and I do not know how to get info from site and show it in UI. I have tried using plugins but do not know how to. I want to get the numbers showing on the site which are constantly updated to be shown in a UI field when refresh button is click. Can someone please help I am stuck over here.
The site is results site which revise the numbers on it daily bases. The numbers are changing and its a active server page.
As Vancete said, WWW could be used to solve this.
Create a Coroutine, load the data from the webpage and then do something with it.
IEnumerator GetDataFromWebpage (string url)
{
WWW webpage = new WWW(url);
while (!webpage.isDone) yield return false;
string content = webpage.text;
. . .
// Do something with <content>
}
You can take a look here:
https://docs.unity3d.com/ScriptReference/WWW.html
So you should create an WWW object with the desired URL, wait for the response, then load the object.text property. After all, do a substring of what you need and you are done!
Feel free to ask if you need some more help.
In the src/AppBundle/Controller folder, there is a file called DefaultController.php.
I'll create url's like below, should I use just DefaultController.php for all URL requests or is it recommended to use a different controller.php file (UserController.php, FeedController.php, etc) for each part of the site? (profile, feed, settings, etc)
I also have another question. As far as I understand, we put our html files in our /App/Resources/views folder to keep them separated. Do I need to create a specific file for each part of the website just like flat PHP? (settings/index.php, settings/password.php, settings/things.php, settings/security.php, etc).
I am not sure whether this question is suitable for SO or not.
settings
/settings
/settings/password
/settings/things
/settings/security
/settings/privacy
/settings/ban
/settings/notifications
/settings/mail
/settings/mobile
/settings/applications
/settings/advertising
/settings/invite
user
/username
/username/photos
/username/friends
/username/posts
feed
/feed
/feed/posts/postid
For both questions is no hard answer. I should create a controller for each part of your website AT LEAST. Theoretical you could throw everything into one controller but it will be a very long list if you are finished. Another problem is that your action names like indexAction will repeat which is of course not possible because every method must have a different name. And names like index1Action, index2Action and so on is also not a proper solution :-). Another helper is to create an own controller for every ENTITY.
Twig files should only be written for one page only or only for a part of a page. Imagine that you have a homepage with last 10 newsitems but also a news page with more news items (maybe with pagination). The newsitems themselves looks the same on both pages. In this case you could make a home.html.twig, a news.html.twig and also a newsitem.html.twig. Both home and news will include newsitem to show the newsitems...
Hope i gave you a light.
I have Routing working in ASP.NET c# WebForms using Microsoft.AspNet.FriendlyUrls but not for all pages.
Here is an example:
routes.MapPageRoute("List/{Location}/{ZipCode}/", "List/{Location}/{ZipCode}/", "~/List.aspx");
On the above mentioned page (List.aspx) in the page_load there are no values.count in the Page.RouteData.
Page.RouteData.Values.Count == 0
I have another page in the same site with this info matched to it:
routes.MapPageRoute("{Location}/{ZipCode}/{Name}/{LocID}/{ID}/{Code}/", "{Location}/{ZipCode}/{Name}/{LocID}/{ID}/{Code}/", "~/place.aspx");
This page (place.aspx) always shows the correct count of Routes.
While on the List page in debug mode I checked the querystring and location and the ZipCode were there.
So, what might cause Page.RouteData to not show in one page but be available in another?
I am pretty new to url routing, but I think I ran into a similar problem and also found the solution. Have you tried:
routes.MapPageRoute("ListDetails/{Location}/{ZipCode}/", "ListDetails/{Location}/{ZipCode}/", "~/List.aspx");
instead of
routes.MapPageRoute("List/{Location}/{ZipCode}/", "List/{Location}/{ZipCode}/", "~/List.aspx");
?
In my case I had:
routes.MapPageRoute(
"ImageDelete",
"Admin/Images/Delete/{nameToKill}",
"~/Admin/Images.aspx"
);
which showed Page.RouteData.Values always empty.
When I changed it to
routes.MapPageRoute(
"ImageDelete",
"Admin/Image/Delete/{nameToKill}", // mind the missing 's'
"~/Admin/Images.aspx"
);
it worked!
I think the route may not start with the URL of a site that actually exists.
I am trying to rewrite a url in wordpress so that I can serve up dynamic content based on variables that are passed. I have a plug in that needs variable data passed into it. Currently I have:
http://xyzsite.com/page/?var1=something
this works fine and passes in a $_GET var. So my next step is to clean up the variable so that it looks like
http://xyzsite.com/page/something
I have done a few google searches and come accross some site that looked promising but I cannot get any of them to work. From what I have read, i need to use
add_rewrite_tag and add_rewrite_rule
After reading through the articles I have added this to my functions.php page:
add_rewrite_tag('%var1%','([^&]+)');
add_rewrite_rule('^page/([^&]+)/?','index.php?p=1141&var1=$matches[1]','top');
when i navigate to the page http://xyzsite.com/page/something i get a 404 error. When i navigate the to http://xyzsite.com/page/?var1=something it is still working fine. So it looks as if my rewrite is not registering or working correctly.
Can someone help me to achieve the above rewrite. FYI my permalink settings is set to post name if that matters at all. Thank you.
I̶'̶m̶ ̶n̶o̶t̶ ̶a̶ ̶r̶e̶g̶e̶x̶ ̶p̶r̶o̶,̶ ̶b̶u̶t̶ ̶I̶ ̶s̶u̶s̶p̶e̶c̶t̶ ̶a̶n̶ ̶i̶s̶s̶u̶e̶ ̶i̶n̶ ̶y̶o̶u̶r̶ ̶r̶e̶w̶r̶i̶t̶e̶ ̶r̶u̶l̶e̶:̶
a̶d̶d̶_̶r̶e̶w̶r̶i̶t̶e̶_̶r̶u̶l̶e̶(̶'̶^̶p̶a̶g̶e̶/̶(̶[̶^̶&̶]̶+̶)̶/̶?̶'̶,̶'̶i̶n̶d̶e̶x̶.̶p̶h̶p̶?̶p̶=̶1̶1̶4̶1̶&̶v̶a̶r̶1̶=̶$̶m̶a̶t̶c̶h̶e̶s̶[̶1̶]̶'̶,̶'̶t̶o̶p̶'̶)̶;̶
̶
̶N̶o̶t̶e̶ ̶t̶h̶e̶ ̶/̶?̶ ̶y̶o̶u̶'̶v̶e̶ ̶a̶d̶d̶e̶d̶ ̶a̶t̶ ̶t̶h̶e̶ ̶e̶n̶d̶.̶ ̶T̶h̶u̶s̶ ̶y̶o̶u̶ ̶s̶h̶o̶u̶l̶d̶ ̶a̶c̶c̶e̶s̶s̶ ̶y̶o̶u̶r̶ ̶p̶a̶g̶e̶ ̶w̶i̶t̶h̶ ̶h̶t̶t̶p̶:̶/̶/̶x̶y̶z̶s̶i̶t̶e̶.̶c̶o̶m̶/̶p̶a̶g̶e̶/̶s̶o̶m̶e̶t̶h̶i̶n̶g̶/̶?̶ ̶a̶n̶d̶ ̶n̶o̶t̶ ̶x̶y̶z̶s̶i̶t̶e̶.̶c̶o̶m̶/̶p̶a̶g̶e̶/̶s̶o̶m̶e̶t̶h̶i̶n̶g̶.̶ ̶H̶a̶v̶e̶ ̶y̶o̶u̶ ̶t̶r̶i̶e̶d̶ ̶i̶f̶ ̶t̶h̶a̶t̶ ̶w̶o̶r̶k̶s̶?̶
The stroked out text above is wrong, as Gustavo Straube pointed out in the comments. Please disregard that proposed solution.
My only last advice is to try adding a flush_rules(); after your last add_rewrite_rule, as stated in http://codex.wordpress.org/Rewrite_API/flush_rules.
Note that you should be accessing your query vars with get_query_var('var_name') instead of trying to access $_GET directly.
I just think about that, easy to do in non cms site, but in wordpress site... i like to know YOUR approach to that problem
I have a BIG site (200 pages)... and at a lot of place, the info#something.com, the 000-000-0000 telephone and send your check to 123 easy street, Canada...
all that email, telephone, and address... should reside in one place (a post or a var) and when you need to insert it you should used the short code [tel] or [email].... but how...
is there a plusgin that can define var, or a tutorial to do that... do you only have to change it ONE for the whole site..
Any idea is welcome.... now, find and remplace is my friend !...
thanks in advance
You could try the Custom Config plugin:
http://wordpress.org/extend/plugins/custom-configs/
It will allow you to create custom global variables that are contained within the CMS (otherwise you'd be declaring these variables within the template config).
Usage to output a variable onto the page would be something like:
<?=get_config('myVariable','default')?>