Url in the Address bar with php, or javascript

.htaccess

    RewriteRule ^info/{0,1}$  index.php?page=info [QSA,L]
RewriteRule ^login/{0,1}$  index.php?page=login [QSA,L]

the same : index = index/

RewriteRule ^info/?$ $1
RewriteRule ^login/?$ $1

javascript:

    reg_e=/#$/; if(!window.location.href.match(reg_e)) { 
	window.location.href = decodeURIComponent(window.location.href)+"#";} 

it's working... good I have problem that when someone try to add '/' or any at the final url http://example.com/info/# will return http://example.com/info# or http://example.com/info/# but page will change nothing ? Can you help me establish any rules for none breaking web addresses at ends of lines?

example : http://example.com/info# <- base url

http://example.com/info/# to be => http://example.com/info#

or : http://example.com/info/# <= or if anyone add '/@-' e.tc. the web will be nothing change.

And when I click 'info' and add '/' [http://example.com/info/#, it's ok. but i click other link it will be : http://example.com/info/login# <- RewriteRule ^login/?$ $1 instead of: [http://example.com/login/#

if remove #RewriteRule ^login/?$ $1 ->> http://example.com/login# when add '/' handle => css wont load.

'info' and 'login are the same level in index folder.

i'd tried "<base href='/' /> but not working.

how to have a safe url? thanks your opions.

Upvotes: 1

Views: 44

Answers (1)

Christian
Christian

Reputation: 1577

I am not 100% sure what you want here but it seems as though you want a link to redirect from base URL and not the relative URL.

Say your link is this:

<a href="login">Login</a>

Try this instead

<a href="/login">Login</a>

The / at the beginning will say to go back to the base URL and start from there. Let me know if I missed the point completely though :)

Upvotes: 1

Related Questions