Alex
Alex

Reputation: 5247

creating a php website with user-friendly navigation

We are building a website where user has to login in order to view site's content (similar to what facebook and twitter use)

The problem is that our site's navigation is completely messed up:

In comparison to facebook (url):

Why do sites like facebook have so clean URLs? How do they do it? I'd like to create a clean website, with clean/user-riendly URLs (without # or ? and & and =) - where do I start? Do we need to use any framework (yii, zend, etc..)?

Upvotes: 0

Views: 206

Answers (3)

Dave
Dave

Reputation: 433

yeah, you gotta use mod-re-write.

for example, this is how to change sitename.com/login_success.php#page2 into sitename.come/page2:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>

#first, what is the original request
RewriteCond %{THE_REQUEST} /login_success.php#page([0-9]*)
# now use regex to redirect to the clean url structure
RewriteRule ^$ /page%1? [R=301,L,NE]
# now make the clean url serve the content from the ugly one
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page([0-9]+) /login_success.php#page$1 [L]

I'm not quite sure about that last regex match, but I hope this gets you on the right track!

Upvotes: 2

Nick Pickering
Nick Pickering

Reputation: 3185

They use mod_rewrite and similar tools to clean up their URLs.

mod_rewrite is available on Apache. The IIS equivalent is named URL Rewrite.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

http://www.iis.net/downloads/microsoft/url-rewrite

You don't need to use a special framework to get this to work, but it helps ease the process, as many frameworks have this feature built-in.

One that comes to mind is Wordpress. Wordpress gives you great control over how this works without having to touch the configuration files too much.

Upvotes: 0

Jaydeep Rajput
Jaydeep Rajput

Reputation: 3673

I believe considerable amount of coding is done in your case.So it would not be advisable to switch to some framework like yii or zend now, this decision should be taken earlier.

Check how to simplify the url.

You can use mod_rewrite of apache web server.

Upvotes: 1

Related Questions