473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically Custom URL Rewritting

245 100+
I have developed a website for open source plugins. I want to do the URL rewriting. But as i am new in this so i need expert help in this regard.
This is my website URL

Header Menu is drawing dynamically. I mean it's a database oriented. Now i want if some one click on jQuery Link, My URL become

Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/jquery/
instead of
Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/index.php?id=1
if my website is static then i can do it using .htaccess but i don't know what id is coming when some one click on the link in header menu. Even i want if some click on sub link of jquery means first select jquery and then click on "Accordions | Menu | Form" it the URL must look like


Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/jquery/accordions-menu-form/
instead of
Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/index.php?id=5
Kindly help me out to sort out this issue i will be very grateful to him/her and it's really appriciated.

Thanks in Advance,
Mohsin Rafique
Apr 5 '10 #1
2 2687
Markus
6,050 Expert 4TB
There is functionality within mod_rewrite for performing lookups with RewriteMap, however I'm not sure how efficient this is.

Another way of approaching this task is to have an alias for each id in your database table (assuming you're using a database).

Table:
Expand|Select|Wrap|Line Numbers
  1. |==============|
  2. | id |   alias |
  3. |==============|
  4. |  1 |  jquery |
  5. |  2 |     php |
  6. |  3 | c-sharp |
  7. |==============|
  8.  
Example code (PHP & MySQL):
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Example URL request: http://yoursite/?alias=jquery
  4. // ...
  5. // Connect to your database 
  6. // ...
  7.  
  8. if (isset($_GET['alias'])) {
  9.     $alias = $_GET['alias'];
  10.     // Remember to sanitize your data!
  11.     // Then use this alias as a lookup in your database table
  12.     $sql = "SELECT * FROM `categories` WHERE `alias` = '$alias' LIMIT 1";
  13.     // Etc.
  14. }
  15.  
Then you just have to rewrite the URL from http://yoursite?alias=jquery to http://yoursite/jquery
Apr 6 '10 #2
neovantage
245 100+
First of all thanks Markus for response.

Your solution meets my query but there is a problem in this case and that is.

If we have 2 processors of different comopanies Intel and AMD.
Your given solution works in scenerio
Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/intel/processor/
and
Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/amd/processor/
but 404 error will come if some one write
Expand|Select|Wrap|Line Numbers
  1. http://www.themosaicdesigns.com/processor/
What will we do in this case...?

One solution which i have if no page found then it takes to a page where all the categories are list down.

Is there any other possible solution for this...?
Apr 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Ken Varn | last post by:
I want to add my own custom <STYLE> section in the <HEAD> section of my ASP.NET page within a custom control. Can someone tell me how I can have my custom control add tags to the <HEAD> section of...
1
by: Wannabe_Geek | last post by:
Hi Iam new to MS .Net technology just getting along with it....I created a custom control ,which takes in a query and displays the data in a tabular format....something similar to a datagrid. ...
0
by: Earl Teigrob | last post by:
I am building a custom control that I want to server as a container for child controls that can be dynamically added to this control. I can persist the child controls that are added to my custom...
3
by: David Freeman | last post by:
Hi There! I'm having trouble dynamically adding custom controls. My custom controls does not use code-behind but only <script /> block for programming. So as a result, I don't need to compile my...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
4
by: =?Utf-8?B?QWJoaQ==?= | last post by:
I am using Reflection to invoke methods dynamically. I have got a special requirement where I need to pass a value to method by setting the custom method attribute. As I cannot change the...
29
by: Quarco | last post by:
This one is driving me nuts.... var tbl = document.createElement("table"); var tbody = document.createElement("tbody"); for(var i=0; i<10; i++) { var row =...
1
by: Joe | last post by:
asp.net 2.0 I recently converted a website project to a WAP. I the process I have moved our composite controls into their own subfolder. I have removed the Register directives from the...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.