Welcome Guest, Not a member yet? Register   Sign In
another CI in subdirectory?
#1

[eluser]JackMeUp[/eluser]
Hello,

I have a CI site set up to use urls like:

- www.dn.com/
- www.dn.com/home
- www.dn.com/about

Now I want to add a working copy of the site under folder /testnew

- www.dn.com/testnew/about , etc...

This seems to be working for the home page only. Whenever I click a link, for example to
www.dn.com/testnew/contact, it loads www.dn.com/contact instead. I don't understand why.
Does the answer lie in .htaccess, or routes.php? And in which CI instance?
Here is my .htaccess

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^dn.ca
RewriteRule (.*) http://www.dn.ca/$1 [R=301,L]

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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
    #This last condition enables access to the images and css folders, and the robots.txt file
    #Submitted by Michael Radlmaier (mradlmaier)
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    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>

Thanks for any tips.

Jack.
#2

[eluser]überfuzz[/eluser]
How are the links mustered? If you're planning to move the site around, say to a sub-folder, you could render your links like this.

Code:
<a href="&lt;?php echo current_url(); ?&gt;/this_is_here_in_this_subfolder_to">Link</a>

May not work in all scenarios but I get the idea of flexibility.
#3

[eluser]danmontgomery[/eluser]
You seem to be mixing and matching your .htaccess

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Will only route paths that do not exist

Code:
RewriteCond $1 !^(index\.php|images|robots\.txt|css)

Will only route things not listed here... Since you're already not routing existing files & directories, this line will never do anything. Unless these files don't actually exist, in which case you'd just get an apache 404 instead of a CI 404.

Since you have a separate installation in /testnew, you would need a new htaccess for /testnew, and you would need to change RewriteBase from / to /testnew/
#4

[eluser]JackMeUp[/eluser]
[quote author="noctrum" date="1273537640"]...you would need a new htaccess for /testnew, and you would need to change RewriteBase from / to /testnew/[/quote]

Ding ding ding WINNARRR !

That seems to do the trick, thanks for your input guys!

Jack.




Theme © iAndrew 2016 - Forum software by © MyBB