How to make nicer PHP urls [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to replace my links appeared in my page's adressbar.
Now the links have this format: http://mypage.com/index.php?page=contact
And I want this format: mypage.com/contact
How to do that?
(No links please, I need example.)
Update:
This is one possible solution that worked:
RewriteEngine on
RewriteRule ^([^/.]+)?$ index2.php?page=$1 [L]

Take a look at htaccess and mod_rewrite.
You asked for no links, so I'll let you Google them yourself.
Once you have a chosen path, try it out and if you can't get it working come back with examples of what you've tried and in what way they didn't work.

Related

Htaccess to convert 'GET' to slashes [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I currently have the page '/tags.php?id=foo', and want it to display in the browser as '/tags/foo'. How might I do this with the .htaccess file?
EDIT
I've tried the solution given below and read up a little bit on Regex, but it's still not quite working how I need it to - is it possible once using the .htaccess mod_rewrite to still derive the $_GET data from the URL to use in code?
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^tags/([^/]+)/?$ /tags.php?id=$1 [L,QSA]

Can I find what files are using when a website page is ran? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I just received a source from my customer (it's written by PHP Generally), I try to read it and glance at database. I realize that it's very mess, some webpage's content is also saved in database. So, I want to find files are using by browser and I mean that php files, I want to edit them. Can I do that?
P/S: I'm sorry if this article bother you
Hi At any point you need to know what functions, what includes and what arguments are being passed just use debug_print_backtrace() function in your code.
for further reading follow http://www.php.net/manual/en/function.debug-print-backtrace.php

How to do this: example.com/users/user1 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to make a url to look like example.com/users/user?
I do not use a framework and I write procedural PHP code.
You need somthing like this? Not clear what is your requirement. Check this blog for more
Rewriting example.com/user.php?username=xyz to example.com/xyz
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
Refer htaccess2 tricks

How do I hide the name of my page but keep the dynamically created page title [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the following URL:
www.mysite/apage.php?product_id=295-Product-name-in-a-color
I would like the following:
www.mysite/id=295-Product-name-in-color
The product name and colour are triggered from a different page.
I can redirect the actual apage.php using .htaccess however I lose everything else and it won't find my page.
Any help welcome
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^id=([^/]+)-(.+)$ /apage.php?product_id=$1-$2 [L,QSA,NC]

How to implement Human Readable URLS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I was wondering what is the best way of learning how to get human readable urls on my sites.
My understanding of a human readable URL is this
www.example.com/news/articles/how-to-make-pancakes
rather than something like this
www.example.com/news.php?articleId=100001
where 100001 is the id of my articel in an SQL Database.
Any help would be much appreciated.
UPDATE:
I have tried to Google Human Readable URL's and Semantic URLs but could not find a page/tutorial that matched what I was looking for. I
Look into URL rewriting http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
For your example a simple .htaccess rule could make that change
sample URL: http://example.com/articles/10001/how-to-make-pancakes
RewriteEngine on
RewriteRule ^articles/(.*)/(.*)$ articles.php?id=$1&title=$2 [NC]

Categories