Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]url redirecting
#1

[eluser]kishore[/eluser]
Hi everyone,

Can Someone help me with url-rewriting,

I have an application developed in code-igniter, which allows users to create their own page, such that each user has their own page next to the baseurl,

for example: the actual url is http://localhost/mydomain/

when the user creates his own page, he should be able to view his page at http://localhost/mydomain/user

means no index.php in between the username and the domain name and the user name is different for each user. I have learnt that this can be done using .htaccess file, please help me with this, below is my .htaccess file given.

.htaccess file


<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /mydomain
RewriteCond %{REQUEST_URI} ^!mydomain/index.php/(.*)
RewriteRule /mydomain/index.php/ownername/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [NC,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 http://localhost/mydomain/index.php
</IfModule>

I don't know where Iam going wrong or my approach is correct at all, Please help me soon.

Thanks in Advance.
#2

[eluser]Xclamation Design[/eluser]
Try this:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /yoursite/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

You also need to make sure that your config is set correctly in /system/application/config/config.php and set the $config['index_page'] as shown below:

Code:
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";
#3

[eluser]kishore[/eluser]
Hi,

Thanks for the reply,

I had almost lost hope, that anybody is going to help me or not.

Only you have replied me, I appreciate you a lot for this post,

But I have solved this issue by the following method.

may be its the right way but working fine for my application purpose


Here's the htaccess file Iam using.


<IfModule mod_rewrite.c>
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/?$ mysite/index.php/mysettings/owner/$2
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/([0-9]+) mysite/index.php/mysettings/ownItem/$2/$4
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/([a-z]+)?$ mysite/index.php/mysettings/owner/$2/$3
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/([a-z]+)/([0-9]+) mysite/index.php/mysettings/customer/$2/$3
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/([0-9]+)/soldprocess mysite/index.php/mysettings/soldprocess/$2/$3
</IfModule>



This is working fine in my localhost.

But I have morethan one applications running on my server all requiring .htaccess files.

If I use the above htaccess file its blocking all of the other applications, Can you / any one me

how to deal with multiple .htaccess files, such that all of my applications use their own htaccess files,

without colliding with the other htaccess files.


Thanks in advance.
#4

[eluser]Xclamation Design[/eluser]
Hi,

Is your .htaccess file in the localhost root?? or in the app root?

Can you tell me how you have your applications stored on your local web server?

Eg. http://localhost/app1/, http://localhost/app2/, http://localhost/app3/

If you have your apps set up as in the example above, you should have a .htaccess in each apps root folder. But it looks like you have your .htaccess in the root of localhost??

Hope this helps...
#5

[eluser]kishore[/eluser]
Hello there,

Thanks for your reply,

You guessed it right I have my .htaccess file in the root of my server,

that is in localhost, where all of the applications are installed.

But in apache you have a parameter called Access FileName which specifies

that which htaccess file the apache server has to look for which I guess cannot be declared

seperately for each application, there it is creating problem.

Hope I have pointed the problem correctly, though I have not tried with multiple Access FileName

parameters since its my live server, please help me and guide me whether I am correctly interpreting the problem or not.

Thanks in advance.
#6

[eluser]Xclamation Design[/eluser]
I think you are slightly complicating things... :-)

Basically, at the moment you have a .htaccess file in your localhost:

Eg. http://localhost/.htaccess

This .htaccess is pointing to a subfolder. However, you should remove the above .htaccess and put it in each subfolder:

Eg.
http://locahost/mysite/.htaccess
http://locahost/myothersite/.htaccess

This would also mean removing the 'mysite' part from all of you .htaccess Rewrite rules:

Eg.
Code:
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/?$  mysite/index.php/mysettings/owner/$2
would need to be changed to:
Code:
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/?$  index.php/mysettings/owner/$2

You cetainly dont need to be messing around with Apache parameters.

Let us know how you get on and hopefully you can come back and mark this post as 'SOLVED' :coolsmirk:
#7

[eluser]kishore[/eluser]
[quote author="Xclamation Design" date="1267216173"]I think you are slightly complicating things... :-)

Basically, at the moment you have a .htaccess file in your localhost:

Eg. http://localhost/.htaccess

This .htaccess is pointing to a subfolder. However, you should remove the above .htaccess and put it in each subfolder:

Eg.
http://locahost/mysite/.htaccess
http://locahost/myothersite/.htaccess

This would also mean removing the 'mysite' part from all of you .htaccess Rewrite rules:

Eg.
Code:
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/?$  mysite/index.php/mysettings/owner/$2
would need to be changed to:
Code:
RewriteRule ^(.*)/([0-9]+)/([a-zA-Z]+)/?$  index.php/mysettings/owner/$2

You cetainly dont need to be messing around with Apache parameters.

Let us know how you get on and hopefully you can come back and mark this post as 'SOLVED' :coolsmirk:[/quote]


Hi everyone,

HI Xclamation Design,

Haa finally its solved, actually I had another .htaccess file enabled in the local host itself.

I just removed that one and also removed the Access Filename Attribute in apache and it worked

like a charm,

Thanks for the help, really I appreciate you.:wow:

Thanks a lot.

But I don't know how to mark the topic as SOLVED. :-P
#8

[eluser]Xclamation Design[/eluser]
Hi kishore...

Just glad I could help...

To mark the post as solved, I think you just edit the post and add '[SOLVED]' (without the '') to the posts title.

Happy coding!
#9

[eluser]kishore[/eluser]
[quote author="Xclamation Design" date="1267652255"]Hi kishore...

Just glad I could help...

To mark the post as solved, I think you just edit the post and add '[SOLVED]' (without the '') to the posts title.

Happy coding![/quote]


HI Xclamation, Thanks once again, but I did not find any option to edit the title and add some extra text to it.
#10

[eluser]Xclamation Design[/eluser]
Dont worry about it too much... At least we know it's solved... :coolsmirk:




Theme © iAndrew 2016 - Forum software by © MyBB